Part Number Hot Search : 
SMAJ5 TC11V P391M2 2SC5172 NTE1766 55215KF MC10C ISL65
Product Description
Full Text Search
 

To Download SN8P22121 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 1 version 1.0 sn8p2212 series user?s manual sn8p2213 SN8P22121 sn8p2212 s s o o n n i i x x 8 8 - - b b i i t t m m i i c c r r o o - - c c o o n n t t r r o o l l l l e e r r sonix reserves the right to make change without further notice to any products herein to improve reliability, function or desig n. sonix does not assume any liability arising out of the application or use of an y product or circuit described her ein; neither does it convey a ny license under its patent rights nor the rights of others. sonix products are not designed, intended, or authorized for us as components in systems inten ded, for surgical implant into the body, or other applications intended to suppor t or sustain life, or for any other application in which the fai lure of the sonix product could create a situation where personal injury or death may occu r. should buyer purchase or use sonix products for any such uni ntended or unauthorized application. buyer shall indemnify and hold sonix and its officers, employees, subs idiaries, affiliates and distri butors harmless against all claims, cost, damages, and expenses, and re asonable attorney fees arising out of, dire ctly or indirectly, any claim of pers onal injury or death associated with such unintended or unauthorized use even if such claim alleges that sonix was negligent regarding the design or manufacture of the part.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 2 version 1.0 amendment history version date description ver1.0 2007/2/13 version 1.0
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 3 version 1.0 table of content amendment history ........................................................................................................................ .... 2 1 product overview............................................................................................................... .......... 7 1.1 features ....................................................................................................................... ....................... 7 1.2 system block diagram ................................................................................................................ 8 1.3 pin assignment ..................................................................................................................... ............ 9 1.4 pin descriptions ................................................................................................................... .......... 10 1.5 pin circuit diagrams ................................................................................................................... 11 2 central processor unit (cpu) .............................................................................................. 12 2.1 memory map ............................................................................................................................ ......... 12 2.1.1 program memory (rom) ..................................................................................................... ... 12 2.1.1.1 reset vector (0000h) ................................................................................................... ... 13 2.1.1.2 interrupt vector (0008h)............................................................................................. 14 2.1.1.3 look-up table description........................................................................................ 16 2.1.1.4 jump table description ............................................................................................... 18 2.1.1.5 checksum calculation .............................................................................................. 20 2.1.2 code option table ........................................................................................................ .......... 21 2.1.3 data memory (ram)........................................................................................................ .......... 22 2.1.4 system register.......................................................................................................... .............. 23 2.1.4.1 system register table ................................................................................................ 23 2.1.4.2 system register description ................................................................................... 23 2.1.4.3 bit definition of system register........................................................................... 24 2.1.4.4 accumulator ............................................................................................................ ....... 26 2.1.4.5 program flag ........................................................................................................... ........ 27 2.1.4.6 program counter ........................................................................................................ .. 28 2.1.4.7 y, z registers ......................................................................................................... ........... 31 2.1.4.8 r registers ............................................................................................................ ............. 32 2.2 addressing mode .......................................................................................................................... 3 3 2.2.1 immediate addressing mode.............................................................................................. 33 2.2.2 directly addressing mode ................................................................................................. 33 2.2.3 indirectly addressing mode ............................................................................................. 33 2.3 stack operation...................................................................................................................... ...... 34 2.3.1 overview ................................................................................................................. .................... 34 2.3.2 stack registers .......................................................................................................... .............. 35 2.3.3 stack operation example.................................................................................................. .. 36 3 reset .......................................................................................................................... ........................... 37
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 4 version 1.0 3.1 overview ....................................................................................................................... .................... 37 3.2 power on reset.......................................................................................................................... ..... 39 3.3 watchdog reset .......................................................................................................................... .. 39 3.4 brown out reset .......................................................................................................................... . 40 3.4.1 brown out description .................................................................................................... .... 40 3.4.2 the system operating voltage decsription............................................................... 41 3.4.3 brown out reset improvement......................................................................................... 42 3.5 external reset .......................................................................................................................... .... 43 3.6 external reset circuit ............................................................................................................. 43 3.6.1 simply rc reset circuit .................................................................................................. ................ 43 3.6.2 diode & rc reset circuit ................................................................................................. .............. 44 3.6.3 zener diode reset circuit ................................................................................................ ............... 44 3.6.4 voltage bias reset circuit............................................................................................... ................ 45 3.6.5 external reset ic........................................................................................................ ..................... 45 4 system clock ................................................................................................................... ............... 46 4.1 overview ....................................................................................................................... .................... 46 4.2 clock block diagram................................................................................................................. 46 4.3 oscm register ....................................................................................................................... .......... 47 4.4 system high clock ....................................................................................................................... 48 4.4.1 external high clock...................................................................................................... ....... 48 4.4.1.1 crystal/ceramic........................................................................................................ ..... 49 4.1.1.2 external clock signal............................................................................................... 50 4.2 system low clock ........................................................................................................................ 51 4.2.1 system clock measurement ............................................................................................... 52 5 system operation mode .......................................................................................................... .53 5.1 overview ....................................................................................................................... .................... 53 5.2 system mode switching example ......................................................................................... 54 5.3 wakeup ......................................................................................................................... ...................... 56 5.3.1 overview ................................................................................................................. .................... 56 5.3.2 wakeup time.............................................................................................................. ................. 56 6 interrupt...................................................................................................................... ..................... 57 6.1 overview ....................................................................................................................... .................... 57 6.2 inten interrupt enable register ......................................................................................... 58 6.3 intrq interrupt request register....................................................................................... 59 6.4 gie global interrupt operation .......................................................................................... 59 6.5 push, pop routine........................................................................................................................ ... 60 6.6 int0 (p0.0) interrupt operation............................................................................................... 61 6.7 t0 interrupt operation.............................................................................................................. 63
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 5 version 1.0 6.8 tc0 interrupt operation ........................................................................................................... 64 6.9 usb interrupt operation .......................................................................................................... 65 6.10 wakeup interrupt operation ............................................................................................... 66 6.11 sio interrupt operation.......................................................................................................... 67 6.12 multi-interrupt operation ................................................................................................... 68 7 i/o port ....................................................................................................................... ......................... 69 7.1 i/o port mode ........................................................................................................................... ........ 69 7.2 i/o pull up register ...................................................................................................................... 7 0 7.3 i/o open-drain register .............................................................................................................. 71 7.4 i/o port data register ................................................................................................................ 72 7.5 i/o port1 wakeup control register..................................................................................... 72 8 timers ......................................................................................................................... ......................... 73 8.1 watchdog timer.......................................................................................................................... .. 73 8.2 timer 0 (t0) ........................................................................................................................... .............. 75 8.2.1 overview ................................................................................................................. .................... 75 8.2.2 t0m mode register........................................................................................................ .......... 75 8.2.3 t0c counting register.................................................................................................... ...... 76 8.2.4 t0 timer operation sequence ............................................................................................ 77 8.3 timer c0 (tc0) .......................................................................................................................... .......... 78 8.3.1 overview ................................................................................................................. .................... 78 8.3.2 tc0m mode register ....................................................................................................... ........ 78 8.3.3 tc0c counting register ................................................................................................... .... 79 8.3.4 tc0 timer operation sequence ......................................................................................... 79 9 universal serial bus (usb) ..................................................................................................... .81 9.1 overview ....................................................................................................................... .................... 81 9.2 usb machine ........................................................................................................................ ............. 81 9.3 usb interrupt...................................................................................................................... ............ 82 9.4 usb enumeration .................................................................................................................... ...... 83 9.5 usb registers ...................................................................................................................... ............ 83 9.5.1 usb device address register ............................................................................................. 8 3 9.5.2 usb status register...................................................................................................... .......... 84 9.5.3 usb data count register .................................................................................................. ... 85 9.5.4 usb endpoint 0 enable register ....................................................................................... 85 9.5.5 usb endpoint 1 enable register ....................................................................................... 86 example: check the endpoint 1?s in/out request................................................................................. .87 example: check the endpoint 1?s out request.................................................................................... ... 87 9.5.6 usb endpoint 2 enable register ....................................................................................... 88 9.5.7 usb data pointer 0 register .............................................................................................. .88
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 6 version 1.0 9.5.8 usb data register........................................................................................................ ............ 90 9.5.9 usb data pointer 1 register .............................................................................................. .90 9.5.10 usb data register....................................................................................................... ........... 91 9.5.11 upid register ........................................................................................................... ............... 91 9.5.12 usb endpoint 1 out toke n data bytes counter....................................................... 91 9.5.13 usb endpoint 2 out toke n data bytes counter....................................................... 91 10 serial input/output transceiver .................................................................................. 92 10.1 overview ....................................................................................................................... .................. 92 10.2 siom mode register .................................................................................................................... 94 10.3 siob data buffer ......................................................................................................................... 95 10.4 sior register description....................................................................................................... 95 11 instruction table .............................................................................................................. ..... 98 12 development tool ............................................................................................................... ... 99 12.1 ice (i n c ircuit e mulation )........................................................................................................... 99 12.2 sn8p2213 ev- kit .......................................................................................................................... 100 13 electrical characteristic ............................................................................................ 101 13.1 absolute maximum rating .............................................................................................. 101 13.2 electrical characteristic............................................................................................. 101 14 otp programming pin........................................................................................................... 1 02 14.1 the pin assignment of easy writer transition board socket ..................... 102 14.2 programming pin mapping................................................................................................ 103 15 package information ......................................................................................................... 104 15.1 sk-dip 24 pin ............................................................................................................................ ... 104 15.2 p-dip 20 pin ............................................................................................................................ ...... 105 15.3 p-dip 18 pin ............................................................................................................................ ...... 106 15.4 sop 24 pin............................................................................................................................ ......... 107 15.5 sop 20 pin............................................................................................................................ ......... 108 15.6 sop 18 pin............................................................................................................................ ......... 109 15.7 ssop 24 pin............................................................................................................................ ....... 110 15.8 ssop 20 pin............................................................................................................................ ....... 111 16 marking definition............................................................................................................. .. 112 introduction ................................................................................................................... ................... 112 marking indetification system................................................................................................ 112 marking example ........................................................................................................................ ..... 113 datecode system ......................................................................................................................... ..... 113
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 7 version 1.0 1 product overview 1.1 features ) features selection table timer chip rom ram stack t0 tc0 sio wake-up pin no. package sn8p2213 4k*16 192*8 8 v v v 14 dip24/sop24/ssop24 SN8P22121 4k*16 192*8 8 v v v 10 dip20/sop20/ssop20 sn8p2212 4k*16 192*8 8 v v v 8 dip18/sop18 ? memory configuration ? 6 interrupt sources. otp rom size: 4k x 16 bits. five internal interrupts: t0, tc0, usb, sio, wakeup ram size: 192 x 8 bits. one external interrupt: int0. ? 8 levels stack buffer ? one sio function for data transfer (serial peripheral interface) ? i/o pin configuration bi-directional: p0, p1, p5. ? two 8-bit timer counters. (t0, tc0) wake-up: p0/p1 level change. pull-up resistors: p0, p1, p5 ? on chip watchdog timer. open-drain: p1.0, p1.1, p5.0, p5.2. external interrupt: p0.0 controlled by pedge. ? two system clocks. external high clock: crystal type 6mhz. ? full speed usb 1.1. internal low clock: rc type 32khz @5v. conforms to usb specification, version 2.0. 3.3v regulator output for usb d+ pin external ? four operating modes. 1.5k ohm pull-up resistor. normal mode: both high and low clocks active. integrated usb transceiver. slow mode: low clock only. supports 1 full speed usb device address, sleep: both high and low clocks stop. 1 control endpoint (endpoint 0) and 2 interrupt green mode: periodical wakeup by timer. endpoints (endpoint 1 and endpoint 2) ? package (chip form support) ? powerful instructions sk-dip/p-dip: 24/20/18 one clocks per instruction cycle (1t) sop: 24/20/18 most of instructions are one cycle only. ssop: 24/20 all rom area jmp instruction. all rom area call address instruction. all rom area lookup table function (movc)
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 8 version 1.0 1.2 system block diagram interrupt control external high osc. acc internal low rc timing generator ram system registers lvd watchdog timer timer & counter p0 p5 p1 sio alu pc flags ir otp rom sio usb sie 3.3v regulator vreg d+ d- pll
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 9 version 1.0 1.3 pin assignment sn8p2213k (sk-dip 24 pins) sn8p2213s (sop 24 pins) sn8p2213x (ssop 24 pins) p1.2 1 u 24 p1.3 p1.1 2 23 p1.4 p1.0 3 22 p1.5 p5.1/sdi 4 21 p1.6 p5.2/sdo 5 20 p1.7 p5.0/sck 6 19 vdd p0.4 7 18 vreg p0.3 8 17 d+ p0.2 9 16 d- p0.1 10 15 vss p0.0/int0 11 14 xout p0.5/rst/vpp 12 13 xin sn8p2213k sn8p2213s sn8p2213x SN8P22121k (sk-dip 20 pins) SN8P22121s (sop 20 pins) SN8P22121x (ssop 20 pins) p1.2 1 20 p1.3 p1.1 2 19 p1.4 p1.0 3 18 p1.5 p5.1/sdi 4 17 vdd p5.2/sdo 5 16 vreg p5.0/sck 6 15 d+ p0.2 7 14 d- p0.1 8 13 vss p0.0/int0 9 12 xout p0.5/rst/vpp 10 11 xin SN8P22121k SN8P22121s SN8P22121x sn8p2212p (p-dip 18 pins) sn8p2212s (sop 18 pins) p1.2 1 u 18 p1.3 p1.1 2 17 p1.4 p1.0 3 16 vdd p5.1/sdi 4 15 vreg p5.2/sdo 5 14 d+ p5.0/sck 6 13 d- p0.1 7 12 vss p0.0/int0 8 11 xout p0.5/rst/vpp 9 10 xin sn8p2212p sn8p2212s
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 10 version 1.0 1.4 pin descriptions pin name type description vdd, vss p power supply input pins for digital circuit. p0.0/int0 i/o p0.0: port 0.0 bi-direction pin. schmitt trigger structure and built-i n pull-up resisters as input mode. built wakeup function. int0: external interrupt 0 input pin. p0[4:0] i/o p0: port 0 bi-direction pin. schmitt trigger structure and built-i n pull-up resisters as input mode. built wakeup function. p1.0 i/o p1.0: port 1.0 bi-direction pin. schmitt trigger structure and built-i n pull-up resisters as input mode. open-drain function controlled by ?p1oc? register. built wakeup function. p1.1 i/o p1.1: port 1.1 bi-direction pin. schmitt trigger structure and built-i n pull-up resisters as input mode. open-drain function controlled by ?p1oc? register. built wakeup function. xout i/o xout: oscillator output pin while external oscillator enable. xin i/o xin: oscillator input pin while external oscillator enable. p0.5/rst/vpp i, p rst is system external reset input pin under ext_rst mode. schmitt trigger structure, active ?low?, normal stay to ?high?. p0.5 is input only pin without pull-up resistor under p0.5 mode. built wakeup function. otp 12.3v power input pin in programming mode. p1[7:2] i/o p1: port 1 bi-direction pin. schmitt trigger structure and built-i n pull-up resisters as input mode. p5.0/sck i/o p5.0: port 5.0 bi-direction pin. schmitt trigger structure and built-i n pull-up resisters as input mode. sck: sio output clock pin. open-drain function controlled by ?p1oc? register. p5.1/sdi i/o p5.1: port 5.1 bi-direction pin. schmitt trigger structure and built-i n pull-up resisters as input mode. sdi: sio data input pin. p5.2/sdo i/o p5.2: port 5.2 bi-direction pin. schmitt trigger structure and built-i n pull-up resisters as input mode. sck: sio data output pin. open-drain function controlled by ?p1oc? register. vreg o 3.3v voltage output from usb 3.3v regulator. d+, d- i/o usb differential data line.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 11 version 1.0 1.5 pin circuit diagrams port 0, 1, 5 structures: pull-up pin output latch pnm, pnur input bus pnm output bus port 1.0, port 1.1 structure: pull-up pin output latch pnm, pnur input bus pnm output bus p1oc open-drain port 0.5 structure: pin ext. reset code option int. bus int. rst
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 12 version 1.0 2 central processor unit (cpu) 2.1 memory map 2.1.1 program memory (rom) ) 4k words rom rom 0000h reset vector user reset vector jump to user start address 0001h . . 0007h general purpose area 0008h interrupt vector user interrupt vector 0009h user program . . 000fh 0010h 0011h . . . . . general purpose area end of user program 0ffch 0ffdh 0ffeh 0fffh reserved
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 13 version 1.0 2.1.1.1 reset vector (0000h) a one-word vector address area is used to execute system reset. ) power on reset (nt0=1, npd=0). ) watchdog reset (nt0=0, npd=0). ) external reset (nt0=1, npd=1). after power on reset, external reset or watchdog timer over flow reset, then the chip will restart the program from address 0000h an d all system registers will be set as default values . it is easy to know rese t status from nt0, npd flags of pflag register. the following example shows the way to define the reset vector in the program memory. ? example: defining reset vector org 0 ; 0000h jmp start ; jump to user program address. ? org 10h start: ; 0010h, the head of user program. ? ; user program ? endp ; end of program
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 14 version 1.0 2.1.1.2 interrupt vector (0008h) a 1-word vector address area is used to execute interr upt request. if any interrupt se rvice executes, the program counter (pc) value is stored in stack buffer and jump to 0008h of program memory to execute the vectored interrupt. users have to define the interr upt vector. the following example shows the wa y to define the interrupt vector in the program memory. ? note:?push?, ?pop? instructions save and load ac c/pflag without (nt0, npd) . push/pop buffer is a unique buffer and only one level. ? example: defining interrupt vector. the in terrupt service routine is following org 8. .code org 0 ; 0000h jmp start ; jump to user program address. ? org 8 ; interrupt vector. push ; save acc and pflag register to buffers. ? ? pop ; load acc and pflag register from buffers. reti ; end of interrupt service routine ? start: ; the head of user program. ? ; user program ? jmp start ; end of user program ? endp ; end of program
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 15 version 1.0 ? example: defining interrupt vector. the interru pt service routine is following user program. .code org 0 ; 0000h jmp start ; jump to user program address. ? org 8 ; interrupt vector. jmp my_irq ; 0008h, jump to interrupt service routine address. org 10h start: ; 0010h, the head of user program. ? ; user program. ? ? jmp start ; end of user program. ? my_irq: ;the head of interrupt service routine. push ; save acc and pflag register to buffers. ? ? pop ; load acc and pflag register from buffers. reti ; end of interrupt service routine. ? endp ; end of program. ? note: it is easy to understand the rules of sonix program from demo programs given above. these points are as following: 1. the address 0000h is a ?jmp? instruction to make the program starts from the beginning. 2. the address 0008h is interrupt vector. 3. user?s program is a loop routine for main purpose application.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 16 version 1.0 2.1.1.3 look-up table description in the rom?s data lookup function, y register is pointed to middle byte address (bit 8~bit 15) and z register is pointed to low byte address (bit 0~bit 7) of rom. after movc instruction executed, t he low-byte data will be stored in acc and high-byte data stored in r register. ? example: to look up the rom data located ?table1?. b0mov y, #table1$m ; to set lookup table1?s middle address b0mov z, #table1$l ; to set lookup table1?s low address. movc ; to lookup data, r = 00h, acc = 35h ; increment the index address for next address. incms z ; z+1 jmp @f ; z is not overflow. incms y ; z overflow (ffh ? 00), ? y=y+1 nop ; ; @@: movc ; to lookup data, r = 51h, acc = 05h. ? ; table1: dw 0035h ; to define a word (16 bits) data. dw 5105h dw 2012h ? ? note: the y register will not increase automatically wh en z register crosses boundary from 0xff to 0x00. therefore, user must take care such situation to avoid loop-up table errors. if z register overflows, y register must be added one. the following inc_yz macro shows a simple method to process y and z registers automatically. ? example: inc_yz macro. inc_yz macro incms z ; z+1 jmp @f ; not overflow incms y ; y+1 nop ; not overflow @@: endm
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 17 version 1.0 ? example: modify above exam ple by ?inc_yz? macro. b0mov y, #table1$m ; to set lookup table1?s middle address b0mov z, #table1$l ; to set lookup table1?s low address. movc ; to lookup data, r = 00h, acc = 35h inc_yz ; increment the index address for next address. ; @@: movc ; to lookup data, r = 51h, acc = 05h. ? ; table1: dw 0035h ; to define a word (16 bits) data. dw 5105h dw 2012h ? the other example of loop-up table is to add y or z index regi ster by accumulator. please be careful if ?carry? happen. ? example: increase y and z register by b0add/add instruction. b0mov y, #table1$m ; to set lookup table?s middle address. b0mov z, #table1$l ; to set lookup table?s low address. b0mov a, buf ; z = z + buf. b0add z, a b0bts1 fc ; check the carry flag. jmp getdata ; fc = 0 incms y ; fc = 1. y+1. nop getdata: ; movc ; to lookup data. if buf = 0, data is 0x0035 ; if buf = 1, data is 0x5105 ; if buf = 2, data is 0x2012 ? table1: dw 0035h ; to define a word (16 bits) data. dw 5105h dw 2012h ?
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 18 version 1.0 2.1.1.4 jump table description the jump table operation is one of multi-address jumpin g function. add low-byte program counter (pcl) and acc value to get one new pcl. if pcl is overflow after pcl+ acc, pch adds one automatically. the new program counter (pc) points to a series jump instructions as a listing t able. it is easy to make a multi-jump program depends on the value of the accumulator (a). ? note: pch only support pc up counting result and doesn?t support pc down counting. when pcl is carry after pcl+acc, pch adds one automatically. if pcl borrow after pcl?acc, pch keeps value and not change. ? example: jump table. org 0x0100 ; the jump table is from the head of the rom boundary b0add pcl, a ; pcl = pcl + acc, pch + 1 when pcl overflow occurs . jmp a0point ; acc = 0, jump to a0point jmp a1point ; acc = 1, jump to a1point jmp a2point ; acc = 2, jump to a2point jmp a3point ; acc = 3, jump to a3point sonix provides a macro for safe jump table function. th is macro will check the rom boundary and move the jump table to the right position automatically. the side e ffect of this macro maybe wastes some rom size. ? example: if ?jump table? crosses over rom boundary will cause errors. @jmp_a macro val if (($+1) !& 0xff00) !!= (($+(val)) !& 0xff00) jmp ($ | 0xff) org ($ | 0xff) endif add pcl, a endm ? note: ?val? is the number of the jump table listing number.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 19 version 1.0 ? example: ?@jmp_a? application in sonix macro file called ?macro3.h?. b0mov a, buf0 ; ?buf0? is from 0 to 4. @jmp_a 5 ; the number of the jump table listing is five. jmp a0point ; acc = 0, jump to a0point jmp a1point ; acc = 1, jump to a1point jmp a2point ; acc = 2, jump to a2point jmp a3point ; acc = 3, jump to a3point jmp a4point ; acc = 4, jump to a4point if the jump table position is across a rom boundary (0x00ff~ 0x0100), the ?@jmp_a? macro will adjust the jump table routine begin from next ram boundary (0x0100). ? example: ?@jmp_a? operation. ; before compiling program. rom address b0mov a, buf0 ; ?buf0? is from 0 to 4. @jmp_a 5 ; the number of the jump table listing is five. 0x00fd jmp a0point ; acc = 0, jump to a0point 0x00fe jmp a1point ; acc = 1, jump to a1point 0x00ff jmp a2point ; acc = 2, jump to a2point 0x0100 jmp a3point ; acc = 3, jump to a3point 0x0101 jmp a4point ; acc = 4, jump to a4point ; after compiling program. rom address b0mov a, buf0 ; ?buf0? is from 0 to 4. @jmp_a 5 ; the number of the jump table listing is five. 0x0100 jmp a0point ; acc = 0, jump to a0point 0x0101 jmp a1point ; acc = 1, jump to a1point 0x0102 jmp a2point ; acc = 2, jump to a2point 0x0103 jmp a3point ; acc = 3, jump to a3point 0x0104 jmp a4point ; acc = 4, jump to a4point
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 20 version 1.0 2.1.1.5 checksum calculation the last rom addresses are reserved area. user should av oid these addresses (last address) when calculate the checksum value. ? example: the demo program shows how to calculated checksum from 00h to the end of user?s code. mov a,#end_user_code$l b0mov end_addr1, a ; save low end address to end_addr1 mov a,#end_user_code$m b0mov end_addr2, a ; save middle end address to end_addr2 clr y ; set y to 00h clr z ; set z to 00h @@: movc b0bset fc ; clear c flag add data1, a ; add a to data1 mov a, r adc data2, a ; add r to data2 jmp end_check ; check if the yz address = the end of code aaa: incms z ; z=z+1 jmp @b ; if z != 00h calculate to next address jmp y_add_1 ; if z = 00h increase y end_check: mov a, end_addr1 cmprs a, z ; check if z = low end address jmp aaa ; if not jump to checksum calculate mov a, end_addr2 cmprs a, y ; if yes, check if y = middle end address jmp aaa ; if not jump to checksum calculate jmp checksum_end ; if yes checksum calculated is done. y_add_1: incms y ; increase y nop jmp @b ; jump to checksum calculate checksum_end: ? ? end_user_code: ; label of program end
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 21 version 1.0 2.1.2 code option table code option content function description high_clk 6mhz 6mhz crystal /resonator for external high clock oscillator. always_on watchdog timer is always on enable even in power down and green mode. enable enable watchdog timer. watchdog timer stops in power down mode and green mode. watch_dog disable disable watchdog function. fhosc/1 instruction cycle is 12 mhz clock. fhosc/2 instruction cycle is 6 mhz clock. fcpu fhosc/4 instruction cycle is 3 mhz clock. reset enable external reset pin. reset_pin p05 enable p0.5 input only without pull-up resister. enable enable rom code security function. security disable disable rom code security function. ? note: fcpu code option is only available for high clock. fcpu of slow mode is flosc/4.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 22 version 1.0 2.1.3 data memory (ram) ) 192 x 8-bit ram address ram location 000h ? ? ? ? ? 07fh general purpose area bank 0 080h ? ? ? ? ? system register bank 0 0ffh end of bank 0 area 80h~ffh of bank 0 store system registers (128 bytes). 100h ? ? ? ? ? bank1 13fh general purpose area bank1
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 23 version 1.0 2.1.4 system register 2.1.4.1 system register table 0 1 2 3 4 5 6 7 8 9 a b c d e f 8 - - r z y - pflag rbank - - - - - - - - 9 - - - - - - - - - - - - - - - - a uda ustatus uctrl ue0e ue 1e ue2e udp0 udr0 udp1 udr1 upid ep1out _cnt ep1out _cnt b - - - - siom sior siob - p0m - - - - - - pedge c p1w p1m - - - p5m - - intrq inten oscm - wdtr tc0r pcl pch d p0 p1 - - - p5 - - t0m t0c tc0m tc0c - - - stkp e p0ur p1ur - - - p5ur - @yz - p1oc - - - - - - f stk7l stk7h stk6l stk6h stk5l stk5h stk4l stk 4h stk3l stk3h stk2l stk2h stk1l stk1h stk0l stk0h 2.1.4.2 system regis ter description r = working register and rom look-up data buffer. y, z = working, @yz and rom addressing register. pflag = rom page and special flag register . rbank = ram bank selection register. uda = usb control register. ue0r~ue2r = endpoint 0~2 control registers. udp0 = usb fifo 0 address pointer. udr0 = usb fifo 0 data buffer by udp0 point to. udp1 = usb fifo 1 address pointer. udr1 = usb fifo 1 data buffer by udp1 point to. ustatus = usb status register. upid = usb bus control register. ep1out_cnt = usb endpoint 1 out token data byte counter ep2out_cnt = usb endpoint 2 out token data byte counter siom = sio mode control register. uctrl= usb control register siob = sio?s data buffer. sior = sio?s clock reload buffer pnm = port n input/output mode register. pedge = p0.0 edge direction register. intrq = interrupt request register. inten = interrupt enable register. oscm = oscillator mode register. wd tr = watchdog timer clear register. tc0r = tc0 auto-reload data buffer. pch, pcl = program counter. pn = port n data buffer. t0m = t0 mode register. t0c = t0 counting register. tc0m = tc0 mode register. tc0c = tc0 counting register. stkp = stack pointer buffer. pnur = port n pull-up resister control register. @yz = ram yz indirect addressing index pointer. p1oc = port 1 open-drain control register. stk0~stk7 = stack 0 ~ stack 7 buffer. p1w = port 1 wakeup control register
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 24 version 1.0 2.1.4.3 bit definition of system register address bit7 bit6 bit5 bit4 bi t3 bit2 bit1 bit0 r/w remarks 082h rbit7 rbit6 rbit5 rbit4 rbit3 rbit2 rbit1 rbit0 r/w r 083h zbit7 zbit6 zbit5 zbit4 zbit3 zbit2 zbit1 zbit0 r/w z 084h ybit7 ybit6 ybit5 ybit4 ybit3 ybit2 ybit1 ybit0 r/w y 086h nt0 npd c dc z r/w pflag 087h rbnks0 r/w rbank 0a0h ude uda6 uda5 uda4 uda3 uda2 uda1 uda0 r/w uda 0a1h bus_rst suspend ep0_setup ep0_in ep0_out ep1_ack ep2_ack r/w ustatus 0a2h ffs2 ffs1 ffs0 uep0oc4 uep0oc3 uep0oc2 uep0oc1 uep0oc0 r/w uctrl 0a3h ue0m1 ue0m0 ue0c3 ue0c2 ue0c1 ue0c0 r/w ue0e 0a4h ue1e ue1m1 ue1m0 ue1c4 ue1c3 ue1c2 ue1c1 ue1c0 r/w ue1e 0a5h ue2e ue2m1 ue2m0 ue2c4 ue2c3 ue2c2 ue2c1 ue2c0 r/w ue2e 0a6h udp04 udp03 udp02 udp01 udp00 r/w udp0 0a7h udr07 udr06 udr05 udr04 udr03 udr02 udr01 udr00 r/w udr0 0a8h udp14 udp13 udp12 udp11 udp10 r/w udp1 0a9h udr17 udr16 udr15 udr14 udr13 udr12 udr11 udr10 r/w udr1 0aah ubde ddp ddn r/w upid 0abh uep1oc4 uep1oc3 uep1oc2 uep1oc1 uep1oc0 r/w ep1out_cnt 0ach uep2oc4 uep2oc3 uep2oc2 uep2oc1 uep2oc0 r/w ep2out_cnt 0b4h senb start srate1 srate0 0 sckmd sedge txrx r/w siom 0b5h sior7 sior6 sior5 sior4 sior3 sior2 sior1 sior0 w sior 0b6h siob7 siob6 siob5 siob4 siob3 siob2 siob1 siob0 r/w siob 0b8h p04m p03m p02m p01m p00m r/w p0m 0bfh p00g1 p00g0 r/w pedge 0c0h p17w p16w p15w p14w p 13w p12w p11w p10w r/w p1w 0c1h p17m p16m p15m p14m p13m p12m p11m p10m r/w p1m 0c5h p52m p51m p50m r/w p5m 0c8h usbirq tc0irq t0irq sioirq wakeirq p00irq r/w intrq 0c9h usbien tc0ien t0ien sioien wakeien p00ien r/w inten 0cah cpum1 cpum0 clkmd stphx r/w oscm 0cch wdtr7 wdtr6 wdtr5 wdtr4 wdtr3 wdtr2 wdtr1 wdtr0 w wdtr 0cdh 0ceh pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 r/w pcl 0cfh pc12 pc11 pc10 pc9 pc8 r/w pch 0d0h p05 p04 p03 p02 p01 p00 r/w p0 0d1h p17 p16 p15 p14 p13 p12 p11 p10 r/w p1 0d5h p52 p51 p50 r/w p5 0d8h t0enb t0rate2 t0rate1 t0rate0 t0tb r/w t0m 0d9h t0c7 t0c6 t0c5 t0c4 t0c3 t0c2 t0c1 t0c0 r/w t0c 0dah tc0enb tc0rate2 tc0rate1 tc0rate0 tc0cks aload0 tc0out pwm0out r/w tc0m 0dbh tc0c7 tc0c6 tc0c5 tc0c4 tc0c3 tc0c2 tc0c1 tc0c0 r/w tc0c 0dfh gie stkpb2 stkpb1 stkpb0 r/w stkp 0e0h p06r p05r p04r p03r p02r p01r p00r w p0ur 0e1h p17r p16r p15r p13r p12r p11r p10r w p1ur 0e5h p57r p56r p55r p54r p53r p52r p51r p50r w p5ur 0e7h @yz7 @yz6 @yz5 @yz4 @yz3 @yz2 @yz1 @yz0 r/w @yz 0e9h p52oc p50oc p11oc p10oc w p1oc 0f0h s7pc7 s7pc6 s7pc5 s7pc4 s7pc3 s7pc2 s7pc1 s7pc0 r/w stk7l 0f1h s7pc12 s7pc11 s7pc10 s7pc9 s7pc8 r/w stk7h 0f2h s6pc7 s6pc6 s6pc5 s6pc4 s6pc3 s6pc2 s6pc1 s6pc0 r/w stk6l 0f3h s6pc12 s6pc11 s6pc10 s6pc9 s6pc8 r/w stk6h 0f4h s5pc7 s5pc6 s5pc5 s5pc4 s5pc3 s5pc2 s5pc1 s5pc0 r/w stk5l 0f5h s5pc12 s5pc11 s5pc10 s5pc9 s5pc8 r/w stk5h 0f6h s4pc7 s4pc6 s4pc5 s4pc4 s4pc3 s4pc2 s4pc1 s4pc0 r/w stk4l 0f7h s4pc12 s4pc11 s4pc10 s4pc9 s4pc8 r/w stk4h 0f8h s3pc7 s3pc6 s3pc5 s3pc4 s3pc3 s3pc2 s3pc1 s3pc0 r/w stk3l
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 25 version 1.0 0f9h s3pc12 s3pc11 s3pc10 s3pc9 s3pc8 r/w stk3h 0fah s2pc7 s2pc6 s2pc5 s2pc4 s2 pc3 s2pc2 s2pc1 s2pc0 r/w stk2l 0fbh s2pc12 s2pc11 s2pc10 s2pc9 s2pc8 r/w stk2h 0fch s1pc7 s1pc6 s1pc5 s1pc4 s1pc3 s1pc2 s1pc1 s1pc0 r/w stk1l 0fdh s1pc12 s1pc11 s1pc10 s1pc9 s1pc8 r/w stk1h 0feh s0pc7 s0pc6 s0pc5 s0pc4 s0 pc3 s0pc2 s0pc1 s0pc0 r/w stk0l 0ffh s0pc12 s0pc11 s0pc10 s0pc9 s0pc8 r/w stk0h ? note: 1. to avoid system error, please be sure to put all the ?0? and ?1? as it indicates in the above table . 2. all of register names had been declared in sn8asm assembler. 3. one-bit name had been declared in sn8asm assembler with ?f? prefix code. 4. ?b0bset?, ?b0bclr?, ?bset?, ?bclr? instructi ons are only available to the ?r/w? registers. 5. for detail description, please refer to the ?system register quick reference table? .
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 26 version 1.0 2.1.4.4 accumulator the acc is an 8-bit data register responsible for trans ferring or manipulating data between alu and data memory. if the result of operating is zero (z) or there is carry (c or dc) occurrence, then these flags will be set to pflag register. acc is not in data memory (ram), so acc can?t be acce ss by ?b0mov? instruction dur ing the instant addressing mode. ? example: read and write acc value. ; read acc data and store in buf data memory. mov buf, a ; write a immediate data into acc. mov a, #0fh ; write acc data from buf data memory. mov a, buf ; or b0mov a, buf the system doesn?t store acc and pfla g value when interrupt executed. a cc and pflag data must be saved to other data memories. ?push?, ?pop? save and load acc, pflag data into buffers. ? example: protect acc and working registers. int_service: push ; save acc and pflag to buffers. ? . ? pop ; load acc and pflag from buffers. reti ; exit interrupt service vector
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 27 version 1.0 2.1.4.5 program flag the pflag register contains the arithm etic status of alu operat ion, system reset status and lvd detecting status. nt0, npd bits indicate system reset status including po wer on reset, lvd reset, reset by external pin active and watchdog reset. c, dc, z bits indicate t he result status of alu operation. 086h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pflag nt0 npd - - - c dc z read/write r/w r/w - - - r/w r/w r/w after reset - - - - - 0 0 0 bit [7:6] nt0, npd: reset status flag. nt0 npd reset status 0 0 watch-dog time out 0 1 reserved 1 0 reset by lvd 1 1 reset by external reset pin bit 2 c: carry flag 1 = addition with carry, subtraction without borrowing, ro tation with shifting out logic ?1?, comparison result 0. 0 = addition without carry, s ubtraction with borrowing signal, rotation wi th shifting out logic ?0?, comparison result < 0. bit 1 dc: decimal carry flag 1 = addition with carry from low nibble, s ubtraction without borrow from high nibble. 0 = addition without carry from low nibble, subtraction with borrow from high nibble. bit 0 z: zero flag 1 = the result of an arithmetic/logic/branch operation is zero. 0 = the result of an arithmetic/logic/branch operation is not zero. ? note: refer to instruction set table for detailed information of c, dc and z flags.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 28 version 1.0 2.1.4.6 program counter the program counter (pc) is a 13-bit binary counter sepa rated into the high-byte 5 and the low-byte 8 bits. this counter is responsible for pointing a location in order to fe tch an instruction for kernel circuit. normally, the program counter is automatically incremented with eac h instruction during program execution. besides, it can be replaced with specific address by execut ing call or jmp instruction. when jmp or call instruction is executed, the desti nation address will be inserted to bit 0 ~ bit 12. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pc - - - pc12 pc11 pc10 pc9 pc8 pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 after reset - - - 0 0 0 0 0 0 0 0 0 0 0 0 0 pch pcl ) one address skipping there are nine instructions (cmprs, incs, incms, de cs, decms, bts0, bts1, b0bts0, b0bts1) with one address skipping function. if the result of these instructions is true, the pc will add 2 steps to skip next instruction. if the condition of bit test instruction is true, the pc will add 2 steps to skip next instruction. b0bts1 fc ; to skip, if carry_flag = 1 jmp c0step ; else jump to c0step. ? ? c0step: nop b0mov a, buf0 ; move buf0 value to acc. b0bts0 fz ; to skip, if zero flag = 0. jmp c1step ; else jump to c1step. ? ? c1step: nop if the acc is equal to the immediat e data or memory, the pc will add 2 steps to skip next instruction. cmprs a, #12h ; to skip, if acc = 12h. jmp c0step ; else jump to c0step. ? ? c0step: nop
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 29 version 1.0 if the destination increased by 1, wh ich results overflow of 0xff to 0x00, the pc will add 2 steps to skip next instruction. incs instruction: incs buf0 jmp c0step ; jump to c0step if acc is not zero. ? ? c0step: nop incms instruction: incms buf0 jmp c0step ; jump to c0step if buf0 is not zero. ? ? c0step: nop if the destination decreased by 1, which results underflo w of 0x00 to 0xff, the pc will add 2 steps to skip next instruction. decs instruction: decs buf0 jmp c0step ; jump to c0step if acc is not zero. ? ? c0step: nop decms instruction: decms buf0 jmp c0step ; jump to c0step if buf0 is not zero. ? ? c0step: nop
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 30 version 1.0 ) multi-address jumping users can jump around the mult i-address by either jmp inst ruction or add m, a instruction (m = pcl) to activate multi-address jumping function. program counter supports ?add m,a? , ?adc m,a? and ?b0add m,a? instructions for carry to pch when pcl overflow automatically. for jump t able or others applications, users can calculate pc value by the three instructions and don?t care pcl overflow problem. ? note: pch only support pc up counting result and doesn?t support pc down counting. when pcl is carry after pcl+acc, pch adds one automatically. if pcl borrow after pcl?acc, pch keeps value and not change. ? example: if pc = 0323h (pch = 03h, pcl = 23h) ; pc = 0323h mov a, #28h b0mov pcl, a ; jump to address 0328h ? ; pc = 0328h mov a, #00h b0mov pcl, a ; jump to address 0300h ? ? example: if pc = 0323h (pch = 03h, pcl = 23h) ; pc = 0323h b0add pcl, a ; pcl = pcl + ac c, the pch cannot be changed. jmp a0point ; if acc = 0, jump to a0point jmp a1point ; acc = 1, jump to a1point jmp a2point ; acc = 2, jump to a2point jmp a3point ; acc = 3, jump to a3point ? ?
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 31 version 1.0 2.1.4.7 y, z registers the y and z registers are the 8-bit buffers. there ar e three major functions of these registers. z can be used as general working registers z can be used as ram data pointers with @yz register z can be used as rom data pointer with the movc instruction for look-up table 084h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 y ybit7 ybit6 ybit5 ybit4 ybit3 ybit2 ybit1 ybit0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset - - - - - - - - 083h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 z zbit7 zbit6 zbit5 zbit4 zbit3 zbit2 zbit1 zbit0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset - - - - - - - - example: uses y, z register as the data pointer to access data in the ram address 025h of bank0. b0mov y, #00h ; to set ram bank 0 for y register b0mov z, #25h ; to set location 25h for z register b0mov a, @yz ; to read a data into acc example: uses the y, z register as data pointer to clear the ram data. b0mov y, #0 ; y = 0, bank 0 b0mov z, #07fh ; z = 7fh, the last address of the data memory area clr_yz_buf: clr @yz ; clear @yz to be zero decms z ; z ? 1, if z= 0, finish the routine jmp clr_yz_buf ; not zero clr @yz end_clr: ; end of clear general purpose data memory area of bank 0 ?
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 32 version 1.0 2.1.4.8 r registers r register is an 8-bit buffer. there ar e two major functions of the register. z can be used as working register z for store high-byte data of look-up table (movc instruction executed, the high- byte data of specified rom address will be stored in r register and the low-byte data will be stored in acc). 082h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r rbit7 rbit6 rbit5 rbit4 rbit3 rbit2 rbit1 rbit0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset - - - - - - - - ? note: please refer to the ?look-up table description? about r regi ster look-up table application.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 33 version 1.0 2.2 addressing mode 2.2.1 immediate addressing mode the immediate addressing mode uses an immediate data to set up the location in acc or specific ram. ? example: move the immediate data 12h to acc. mov a, #12h ; to set an immediate data 12h into acc. ? example: move the immediate data 12h to r register. b0mov r, #12h ; to set an immediate data 12h into r register. ? note: in immediate addressing mode application, th e specific ram must be 0x80~0x87 working register. 2.2.2 directly addressing mode the directly addressing mode moves the cont ent of ram location in or out of acc. ? example: move 0x12 ram location data into acc. b0mov a, 12h ; to get a content of ram location 0x12 of bank 0 and save in acc. ? example: move acc data into 0x12 ram location. b0mov 12h, a ; to get a content of acc and save in ram location 12h of bank 0. 2.2.3 indirectly addressing mode the indirectly addressing mode is to access the memory by the data pointer registers (y/z). ? example: indirectly addressing mode with @yz register. b0mov y, #0 ; to clear y register to access ram bank 0. b0mov z, #12h ; to set an immediate data 12h into z register. b0mov a, @yz ; use data pointer @yz reads a data from ram location ; 012h into acc.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 34 version 1.0 2.3 stack operation 2.3.1 overview the stack buffer has 8-level. these buffers are designed to push and pop up program counter?s (pc) data when interrupt service routine and ?call? inst ruction are executed. the stkp register is a pointer designed to point active level in order to push or pop up data from stack buffer. the stknh and stknl are the stack buffers to store program counter (pc) data. ret / reti call / interrupt stkp = 7 stkp = 6 stkp = 5 stkp = 4 stack level stk7h stk6h stk5h stk4h stack buffer high byte pch stkp stk7l stk6l stk5l stk4l stack buffer low byte pcl stkp stkp - 1 stkp + 1 stkp = 3 stkp = 2 stkp = 1 stkp = 0 stk3l stk2l stk1l stk0l stk3h stk2h stk1h stk0h
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 35 version 1.0 2.3.2 stack registers the stack pointer (stkp) is a 3-bit register to store t he address used to access the st ack buffer, 13-bit data memory (stknh and stknl) set aside for temp orary storage of stack addresses. the two stack operations are writing to the top of the stac k (push) and reading from the top of stack (pop). push operation decrements the stkp and the pop operation increments each time. that makes the stkp always point to the top address of stack buffer and wr ite the last program counter val ue (pc) into the stack buffer. the program counter (pc) value is stored in the stack bu ffer before a call instruction ex ecuted or during interrupt service routine. stack operation is a lifo type (last in and first out). the stack pointer (stkp) and stack buffer (stknh and stknl) are located in t he system register area bank 0. 0dfh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stkp gie - - - - stkpb2 stkpb1 stkpb0 read/write r/w - - - - r/w r/w r/w after reset 0 - - - - 1 1 1 bit[2:0] stkpbn: stack pointer (n = 0 ~ 2) bit 7 gie: global interrupt control bit. 0 = disable. 1 = enable. please refer to the interrupt chapter. ? example: stack pointer (stkp) reset, we strongl y recommended to clear the stack pointers in the beginning of the program. mov a, #00000111b b0mov stkp, a 0f0h~0ffh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stknh - - - snpc12 snpc11 snpc10 snpc9 snpc8 read/write - - - r/w r/w r/w r/w r/w after reset - - - 0 0 0 0 0 0f0h~0ffh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stknl snpc7 snpc6 snpc5 snpc4 snpc3 snpc2 snpc1 snpc0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 stkn = stknh , stknl (n = 7 ~ 0)
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 36 version 1.0 2.3.3 stack operation example the two kinds of stack-save operations re fer to the stack pointer (stkp) and writ e the content of program counter (pc) to the stack buffer are call instructi on and interrupt service. under each conditi on, the stkp decreases and points to the next available stack location. the stack buffer stor es the program counter about the op-code address. the stack-save operation is as the following table. stkp register stack buffer stack level stkpb2 stkpb1 stkpb0 high byte low byte description 0 1 1 1 free free - 1 1 1 0 stk0h stk0l - 2 1 0 1 stk1h stk1l - 3 1 0 0 stk2h stk2l - 4 0 1 1 stk3h stk3l - 5 0 1 0 stk4h stk4l - 6 0 0 1 stk5h stk5l - 7 0 0 0 stk6h stk6l - 8 1 1 1 stk7h stk7l - > 8 1 1 0 - - stack over, error there are stack-restore operations correspond to each push operation to restore the prog ram counter (pc). the reti instruction uses for interrupt service routine. the ret inst ruction is for call instruction. when a pop operation occurs, the stkp is incremented and points to the next free stack loca tion. the stack buffer restores the last program counter (pc) to the program counter registers. the stac k-restore operation is as the following table. stkp register stack buffer stack level stkpb2 stkpb1 stkpb0 high byte low byte description 8 1 1 1 stk7h stk7l - 7 0 0 0 stk6h stk6l - 6 0 0 1 stk5h stk5l - 5 0 1 0 stk4h stk4l - 4 0 1 1 stk3h stk3l - 3 1 0 0 stk2h stk2l - 2 1 0 1 stk1h stk1l - 1 1 1 0 stk0h stk0l - 0 1 1 1 free free -
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 37 version 1.0 3 reset 3.1 overview the system would be reset in three conditions as following. z power on reset z watchdog reset z brown out reset z external reset (only supports external reset pin enable situation) when any reset condition occurs, all syst em registers keep initial status, progra m stops and program counter is cleared. after reset status released, the system boots up and progra m starts to execute from org 0. the nt0, npd flags indicate system reset status. the system can depend on nt0, npd status and go to diffe rent paths by program. 086h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pflag nt0 npd - - - c dc z read/write r/w r/w - - - r/w r/w r/w after reset - - - - - 0 0 0 bit [7:6] nt0, npd: reset status flag. nt0 npd condition description 0 0 watchdog reset watchdog timer overflow. 0 1 reserved - 1 0 power on reset and lvd reset. power voltage is lower than lvd detecting level. 1 1 external reset external reset pin detect low level status.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 38 version 1.0 finishing any reset sequence needs some time. the system provides complete procedures to make the power on reset successful. for different oscillat or types, the reset time is different. that causes the vdd rise rate and start-up time of different oscillator is not fixed. rc ty pe oscillator?s start-up time is very shor t, but the crystal type is longer. under clie nt terminal application, users have to take care the power on reset time for the master terminal requirement. the reset timing diagram is as following. vdd vss vdd vss watchdog normal run watchdog stop system normal run system stop lvd detect level external reset low detect external reset high detect watchdog overflow watchdog reset delay time external reset delay time power on delay time power external reset watchdog reset system status
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 39 version 1.0 3.2 power on reset the power on reset depend no lvd operation for most power- up situations. the power supplying to system is a rising curve and needs some time to achieve the normal voltage. power on reset sequence is as following. z power-up: system detects the power voltage up and waits for power stable. z external reset (only external reset pin enable): system checks external reset pin status. if external reset pin is not high level, the system keeps reset stat us and waits external reset pin released. z system initialization: all system registers is set as initia l conditions and system is ready. z oscillator warm up: oscillator operation is successfully and supply to system clock. z program executing: power on sequence is finished and program executes from org 0. 3.3 watchdog reset watchdog reset is a system protection. in normal condition, system works well and clears watchdog timer by program. under error condition, system is in unknown situation and watchdog can?t be clear by program before watchdog timer overflow. watchdog timer overflow occurs and the system is reset. after watchdog reset, the system restarts and returns normal mode. watchdog reset sequence is as following. z watchdog timer status: system checks watchdog timer overflow stat us. if watchdog timer ov erflow occurs, the system is reset. z system initialization: all system registers is set as initia l conditions and system is ready. z oscillator warm up: oscillator operation is successfully and supply to system clock. z program executing: power on sequence is finished and program executes from org 0. watchdog timer application note is as following. z before clearing watchdog timer, check i/o status and check ram contents c an improve system error. z don?t clear watchdog timer in interrupt vector and interrupt service routine. that can improve main routine fail. z clearing watchdog timer program is only at one part of the program. this way is the best structure to enhance the watchdog timer function. ? note: please refer to the ?watchdog timer? about watchdog timer detail information.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 40 version 1.0 3.4 brown out reset 3.4.1 brown out description the brown out reset is a power dropping condition. the powe r drops from normal voltage to low voltage by external factors (e.g. eft interference or extern al loading changed). the brown out reset would make the system not work well or executing program error. vdd vss v1 v2 v3 system work well area system work error area brown out reset diagram the power dropping might through the voltage range that ?s the system dead-band. the dead-band means the power range can?t offer the system minimum operation power re quirement. the above diagram is a typical brown out reset diagram. there is a serious noise under the vdd, and vdd voltage drops very deep. there is a dotted line to separate the system working area. the above area is the system work well area. the below area is the system work error area called dead-band. v1 doesn?t touch the below area and not effe ct the system operation. but the v2 and v3 is under the below area and may induce the system error occurrence. let system under dead-band includes some conditions. dc application: the power source of dc application is usually using battery . when low battery condition and mcu drive any loading, the power drops and keeps in dead-band. under the situat ion, the power won?t drop dee per and not touch the system reset voltage. that makes the system under dead-band. ac application: in ac power application, the dc power is regulated from ac power source. this kind of power usually couples with ac noise that makes the dc power dirty. or the external loading is very heavy, e. g. driving motor. the loading operating induces noise and overlaps with the dc power. vdd drop s by the noise, and the system works under unstable power situation. the power on duration and power down duration are longer in ac application. the system power on sequence protects the power on successful, but the power do wn situation is like dc low battery condition. when turn off the ac power, the vdd drops slowly and through the dead-band for a while.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 41 version 1.0 3.4.2 the system operat ing voltage decsription to improve the brown out reset needs to know the system minimum operating voltage which is depend on the system executing rate and power level. differe nt system executing rates have differe nt system minimum operating voltage. the electrical characteristic section shows the system voltage to executing rate relationship. vdd (v) system rate (fcpu) system mini. operating voltage. system reset voltage. dead-band area normal operating area reset area normally the system operation voltage ar ea is higher than the system reset voltage to vdd, and the reset voltage is decided by lvd detect level. the system minimum operating voltage rises when the system executing rate upper even higher than system reset voltage. the dead-band definition is the system minimum operat ing voltage above the system reset voltage.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 42 version 1.0 3.4.3 brown out reset improvement how to improve the brown reset condition? there are some methods to improve brown out reset as following. z lvd reset z watchdog reset z reduce the system executing rate z external reset circuit. (zener diode reset circuit, voltage bias reset circuit, external reset ic) ? note: 1. the ? zener diode reset circuit?, ?voltage bi as reset circuit? and ?external reset ic? can completely improve the brown out reset, dc low battery and ac slow power down conditions. 2. for ac power application and enhance eft performance, the s y stem clock is 4mhz/4 ( 1 mips ) and use external reset (? zener diode reset circui t?, ?voltage bias reset circuit?, ?external reset ic?). the structure can improve noise effective and get good eft characteristic. lvd reset: vdd vss system normal run system stop lvd detect voltage power on delay time power system status power is below lvd detect voltage and system reset. the lvd (low voltage detector) is built-in sonix 8-bit mcu to be brown out reset protection. when the vdd drops and is below lvd detect voltage, the lvd would be triggered, an d the system is reset. the lvd detect level is different by each mcu. the lvd voltage level is a point of volt age and not easy to cover all dead-band range. using lvd to improve brown out reset is depend on application requiremen t and environment. if the power variation is very deep, violent and trigger the lvd, the lvd ca n be the protection. if the power variation can touch the lvd detect level and make system work error, the lvd can? t be the protection and need to other reset methods. more detail lvd information is in the electrical characteristic section. watchdog reset: the watchdog timer is a protection to make sure the system executes well. normally the watchdog timer would be clear at one point of program. don?t clear the watchdog timer in several addresses. the system executes normally and the watchdog won?t reset system. when the system is under dea d-band and the execution error, the watchdog timer can?t be clear by program. the watchdog is continuously counti ng until overflow occurrence. the overflow signal of watchdog timer triggers the system to reset, and the system return to normal mode after reset sequence. this method also can improve brown out reset condition and make sure the system to return normal mode. if the system reset by watchdog and the power is still in dead-band, the system reset sequence won?t be successful and the system stays in reset status until the power return to normal range. reduce the system executing rate: if the system rate is fast and the dead-band exists, to redu ce the system executing rate can improve the dead-band. the lower system rate is with lower minimum operating voltage. select the power voltage that?s no dead-band issue and find out the mapping system rate. adjust the system ra te to the value and the syst em exits the dead-band issue. this way needs to modify whole program timing to fit the application requirement. external reset circuit: the external reset methods also can improve brown out rese t and is the complete solution. there are three external reset circuits to improve brown out reset including ?zener di ode reset circuit?, ?voltage bias reset circuit? and ?external reset ic?. these three reset structures use external rese t signal and control to make sure the mcu be reset under power dropping and under dead-band. the external rese t information is described in the next section.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 43 version 1.0 3.5 external reset external reset function is controlled by ?reset_pin? c ode option. set the code option as ?reset? option to enable external reset function. external reset pin is schmitt trigge r structure and low level active. the system is running when reset pin is high level voltage input. the reset pin receives the low voltage and the system is reset. the external reset operation actives in power on and normal running mode. duri ng system power-up, the external reset pin must be high level input, or the system keeps in reset stat us. external reset sequence is as following. z external reset (only external reset pin enable): system checks external reset pin status. if external reset pin is not high level, the system keeps reset stat us and waits external reset pin released. z system initialization: all system registers is set as initia l conditions and system is ready. z oscillator warm up: oscillator operation is successfully and supply to system clock. z program executing: power on sequence is finished and program executes from org 0. the external reset can reset the system during power on duration, and good external reset circuit can protect the system to avoid working at unusual power condition, e.g. brown out reset in ac power application? 3.6 external reset circuit 3.6.1 simply rc reset circuit mcu vdd vss vcc gnd r s t r1 47k ohm c1 0.1uf r2 100 ohm this is the basic reset circuit, and only includes r1 and c1. the rc circuit operation makes a slow rising signal into reset pin as power up. the reset signal is slower than vdd power up timing, and system occurs a power on signal from the timing difference. ? note: the reset circuit is no any protection against unusual power or brown out reset.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 44 version 1.0 3.6.2 diode & rc reset circuit mcu vdd vss vcc gnd r s t r1 47k ohm c1 0.1uf diode r2 100 ohm this is the better reset circuit. the r1 and c1 circuit operation is like the simply reset circuit to make a power on signal. the reset circuit has a simply protection against unusual po wer. the diode offers a power positive path to conduct higher power to vdd. it is can make reset pin voltage le vel to synchronize with v dd voltage. the structure can improve slight brown out reset condition. ? note: the r2 100 ohm resistor of ?simply reset circ uit? and ?diode & rc reset circuit? is necessar y to limit any current flowing into reset pin from external capacitor c in the event of reset pin breakdown due to electrostatic discharge (esd) or electrical over-stress (eos). 3.6.3 zener diode reset circuit mcu vdd vss vcc gnd r s t r1 33k ohm r3 40k ohm r2 10k ohm vz q1 e c b the zener diode reset circuit is a simple low voltage detector and can improve brown out reset condition completely . use zener voltage to be the active level. when vdd vo ltage level is above ?vz + 0. 7v?, the c terminal of the pnp transistor outputs high voltage and mcu operates normal ly. when vdd is below ?vz + 0.7v?, the c terminal of the pnp transistor outputs low voltage and mcu is in reset mode. decide the reset detect voltage by zener specification. select the right zene r voltage to conform the application.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 45 version 1.0 3.6.4 voltage bias reset circuit mcu vdd vss vcc gnd r s t r1 47k ohm r3 2k ohm r2 10k ohm q1 e c b the voltage bias reset circuit is a low cost voltage detector and can improve brown out reset condition completely . the operating voltage is not accurate as zener diode reset ci rcuit. use r1, r2 bias voltage to be the active level. when vdd voltage level is above or equal to ?0.7v x (r1 + r2) / r1?, the c terminal of the pnp transistor outputs high voltage and mcu operates normally. when vdd is below ?0.7v x (r 1 + r2) / r1?, the c terminal of the pnp transistor outputs low voltage and mcu is in reset mode. decide the reset detect voltage by r1, r2 resistances. select the right r1, r2 value to conform the application. in the circuit diagram condition, the mcu?s reset pin level varies with vdd voltage variation, and the differential voltage is 0.7v. if the vdd drops and the voltage lower than reset pin det ect level, the system would be reset. if want to make the reset active earlier, set the r2 > r1 and the cap between vd d and c terminal voltage is larger than 0.7v. the external reset circuit is with a stable current through r1 and r2 . for power consumption issue application, e.g. dc power system, the current must be considered to whole system power consumption. ? note: under unstable power condition as brown out re set, ?zener diode rest circuit? and ?volta g e bias reset circuit? can protects s y stem no an y error occurrence as power droppin g . when power drops below the reset detect volta g e, the s y stem reset would be tri gg ered, and then s y stem executes reset sequence. that makes sure the system work well under unstable power situation. 3.6.5 external reset ic mcu vdd vss vcc gnd r s t reset ic vdd vss rst bypass capacitor 0.1uf the external reset circuit also use external reset ic to enhance mcu reset performance. this is a high cost and good effect solution. by different application and system require ment to select suitable reset ic. the reset circuit can improve all power variation
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 46 version 1.0 4 system clock 4.1 overview the micro-controller is a dual clock sy stem. there are high-speed clock and low-speed clock. the high-speed clock is generated from the external oscillator circuit. the low-sp eed clock is generated from on-chip low-speed rc oscillator circuit (ilrc 16khz @3v, 32khz @5v). both the high-speed clock and the low-sp eed clock can be system clock (fosc). the system clock in slow mode is divided by 4 to be the instruction cycle (fcpu). ) normal mode (high clock): fcpu = fhosc / n , n = 1 ~ 4, select n by fcpu code option. ) slow mode (low clock): fcpu = flosc/4. sonix provides a ?noise filter? controlled by code option. in high noisy sit uation, the noise filter can isolate noise outside and protect system works well. the mi nimum fcpu of high clock is limited at fhosc/4 when noise filter enable. 4.2 clock block diagram fhosc. fcpu = fhosc/1 ~ fhosc/128, noise filter disable. fcpu = fhosc/4 ~ fhosc/128, noise filter enable. flosc. fcpu = flosc/4 cpum[1:0] xin xout stphx hosc fcpu code option fosc fosc clkmd fcpu z hosc: high_clk code option. z fhosc: external high-speed clock. z flosc: internal low-speed rc clock (about 16khz@3v, 32khz@5v). z fosc: system clock source. z fcpu: instruction cycle.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 47 version 1.0 4.3 oscm register the oscm register is an oscillator control regi ster. it controls oscillator status, system mode. 0cah bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 oscm 0 0 0 cpum1 cpum0 clkmd stphx 0 read/write - - - r/w r/w r/w r/w - after reset - - - 0 0 0 0 - bit 1 stphx: external high-speed os cillator control bit. 0 = external high-speed oscillator free run. 1 = external high-speed oscillator free run stop. internal low-speed rc oscillator is still running. bit 2 clkmd: system high/low clock mode control bit. 0 = normal (dual) mode. syst em clock is high clock. 1 = slow mode. system clock is internal low clock. bit[4:3] cpum[1:0]: cpu operating mode control bits. 00 = normal. 01 = sleep (power down) mode. 10 = green mode. 11 = reserved. ? example: stop high-speed oscillator b0bset fstphx ; to stop exter nal high-speed oscillator only. example: when entering the power down mode (sl eep mode), both high-speed oscillator and internal low-speed oscillator will be stopped. b0bset fcpum0 ; to stop external high- speed oscillator and in ternal low-speed ; oscillator called powe r down mode (sleep mode).
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 48 version 1.0 4.4 system high clock the system high clock is from external oscillator. the hi gh clock type is controlled by ?high_clk? code option. high_clk code option description 6mhz the high clock is external high speed oscillator. the typical frequency is 6mhz. 4.4.1 external high clock external high clock includes three mo dules (crystal/ceramic, rc and external clock signal). the high clock oscillator module is controlled by high_clk code option. the start up time of crystal/ceramic and rc type oscillator is different. rc type oscillator?s start-up time is very short, but the crystal?s is longer. the o scillator start-up time decides reset time length.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 49 version 1.0 4.4.1.1 crystal/ceramic crystal/ceramic devices are driven by xin, xout pins. mcu vcc gnd c 20pf xin x o u t vdd vss c 20pf crystal ? note: connect the crystal/ceramic and c as near as po ssible to the xin/xout/vss pins of micro-controller.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 50 version 1.0 4.1.1.2 external clock signal selecting external clock signal input to be system clock is by rc option of high_clk code opt ion. the external clock signal is input from xin pin. xout pin is general purpose i/o pin. mcu vcc gnd vss vdd xin xout external clock input ? note: the gnd of exte rnal oscillator circuit must be as near as possible to vss pin of micro-controller.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 51 version 1.0 4.2 system low clock the system low clock source is the internal low-speed oscill ator built in the micro-contro ller. the low-sp eed oscillator uses rc type oscillator circuit. the frequency is affect ed by the voltage and temperature of the system. in common condition, the frequency of the rc oscillator is about 16khz at 3v and 32khz at 5v. the relation between the rc frequency and voltage is as the following figure. internal low rc frequency 7.52 10.64 14.72 16.00 17.24 18.88 22.24 25.96 29.20 32.52 35.40 38.08 40.80 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 2.12.533.13.33.544.555.566.57 vdd (v) freq. (khz) ilrc the internal low rc supports watchdog clock source and system slow mode controlled by clkmd. ) flosc = internal low rc oscillator (about 16khz @3v, 32khz @5v). ) slow mode fcpu = flosc / 4 there are two conditions to stop internal low rc. one is power down mode, and the other is green mode of 32k mode and watchdog disable. if system is in 32k mode and watchdog disable, only 32k oscillator actives and system is under low power consumption. ? example: stop internal low-speed oscillator by power down mode. b0bset fcpum0 ; to stop external high- speed oscillator and in ternal low-speed ; oscillator called powe r down mode (sleep mode). ? note: the internal low-speed clock can?t be turned off individually. it is controlled by cpum0, cpum1 (32k, watchdog disable) bits of oscm register.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 52 version 1.0 4.2.1 system clock measurement under design period, the users can meas ure system clock speed by software instruction cycle (fcpu). this way is useful in rc mode. example: fcpu instruction cycl e of external oscillator. b0bset p0m.0 ; set p0.0 to be output mode for outputting fcpu toggle signal. @@: b0bset p0.0 ; output fcpu toggle signal in low-sp eed clock mode. b0bclr p0.0 ; measure the fcpu frequency by oscilloscope. jmp @b ? note: do not measure the rc frequency directly from xin; the probe impendence will affect the rc frequency.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 53 version 1.0 5 system operation mode 5.1 overview the chip is featured with low power consumption by switching around four different modes as following. z high-speed mode z low-speed mode z power-down mode (sleep mode) z green mode power down mode (sleep mode) slow mode green mode normal mode clkmd = 1 clkmd = 0 p0, p1 wake-up function active. usb bus. external reset circuit active. cpum1, cpum0 = 01. cpum1, cpum0 = 10. p0, p1 wake-up function active. t0 timer time out. usb bus. external reset circuit active. p0, p1 wake-up function active. t0 timer time out. usb bus. external reset circuit active. system mode switching diagram operating mode description mode normal slow green power down (sleep) remark ehosc running by stphx by stphx stop ilrc running running running stop cpu instruction executi ng executing stop stop t0 timer *active *active *active inactive * active if t0enb=1 tc0 timer *active *active inactive inactive * active if tc0enb=1 watchdog timer by watch_dog code option by watch_dog code option by watch_dog code option by watch_dog code option refer to code option description internal interrupt all active all active t0 all inactive external interrupt all active all active all active all inactive wakeup source - - p0, p1, t0 reset p0, p1, reset z ehosc: external high clock z ilrc: internal low clock (16k rc oscillator at 3v, 32k at 5v)
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 54 version 1.0 5.2 system mode switching example ? example: switch normal/slow mode to power down (sleep) mode. b0bset fcpum0 ; set cpum0 = 1. ? note: during the sleep, only the wakeup pin and reset can wakeup the system back to the normal mode. ? example: switch normal mode to slow mode. b0bset fclkmd ;to set clkmd = 1, change the system into slow mode b0bset fstphx ;to stop external high -speed oscillator for power saving. ? example: switch slow mode to normal mode ( the external high-speed oscillator is still running). b0bclr fclkmd ;to set clkmd = 0 example: switch slow mode to normal mode (the external high-speed oscillator stops). if external high clock stop and program want to switch back normal mode. it is necessary to delay at least 10ms for external clock stable. b0bclr fstphx ; turn on the external high-speed oscillator. mov a, #27 ; if vdd = 5v, internal rc=32khz (typical) will delay b0mov z, a @@: decms z ; 0.125ms x 81 = 10.125ms for external clock stable jmp @b ; b0bclr fclkmd ; change the system back to the normal mode example: switch normal/slow mode to green mode. b0bset fcpum1 ; set cpum1 = 1. ? note: if t0 timer wakeup function is disabled in the green mode, only the wakeup pin and reset pin can wakeup the system backs to the previous operation mode.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 55 version 1.0 example: switch normal/slow mode to green mode and enable t0 wake-up function. ; set t0 timer wakeup function. b0bclr ft0ien ; to disable t0 interrupt service b0bclr ft0enb ; to disable t0 timer mov a,#20h ; b0mov t0m,a ; to set t0 clock = fcpu / 64 mov a,#74h b0mov t0c,a ; to set t0c initial val ue = 74h (to set t0 interval = 10 ms) b0bclr ft0ien ; to disable t0 interrupt service b0bclr ft0irq ; to clear t0 interrupt request b0bset ft0enb ; to enable t0 timer ; go into green mode b0bclr fcpum0 ;to set cpumx = 10 b0bset fcpum1 ? note: during the green mode with t0 wake-up function, the wakeup pin and t0 wakeup the system back to the last mode. t0 wake-up period is controlled by program.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 56 version 1.0 5.3 wakeup 5.3.1 overview under power down mode (sleep mode) or green mode, progra m doesn?t execute. the wakeup trigger can wake the system up to normal mode or slow mode. the wakeup tri gger sources are external trigger (p0, p1 level change), internal trigger (t0 timer overflow) and usb bus toggle. z power down mode is waked up to normal mode. the wakeup trigger is only external trigger (p0, p1 level change and usb bus toggle) z green mode is waked up to last mode (normal mode or slow mode). the wakeup triggers are external trigger (p0, p1 level change), internal trigger (t0 timer overflow) and usb bus toggle. 5.3.2 wakeup time when the system is in power down mo de (sleep mode), the high clock oscilla tor stops. when wake d up from power down mode, mcu waits for 4 internal 6m hz clock or 2048 external 6mhz cloc ks as the wakeup time to stable the oscillator circuit. after the wakeup time, t he system goes into the normal mode. ? note: wakeup from green mode is no wakeup time because the clock doesn?t stop in green mode. the value of the wakeup time is as the following. ?6m_x?tal? mode: the wakeup time = 1/fosc * 2048 (sec) + high clock start-up time ? note: the high clock start-up time is depended on the vdd and o scillator type of high clock. example: in 6m_x?tal mode and power down mode (sle ep mode), the system is waked up. after the wakeup time, the system goes into normal mode. the wakeup time is as the following. the wakeup time = 1/fosc * 2048 = 0.341 ms (fosc = 6mhz) the total wakeup time = 0.341 ms + oscillator start-up time
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 57 version 1.0 6 interrupt 6.1 overview this mcu provides 5 interrupt sources, including 4 inter nal interrupt (t0/tc0/usb/si o) and one external interrupt (int0). the external interrupt can wakeup the chip while t he system is switched from pow er down mode to high-speed normal mode. once interrupt se rvice is executed, the gie bit in stkp regi ster will clear to ?0 ? for stopping other interrupt request. on the contra st, when interrupt service exit s, the gie bit will set to ?1? to accept the next interrupts? request. all of the interrupt request si gnals are stored in intrq register. inten interrupt enable register interrupt enable gating intrq 2-bit latchs p00irq t0irq interrupt vector address (0008h) global interrupt request signal int0 trigger t0 time out tc0 time out usb process end sio transmit ready tc0irq usbirq sioirq i/o pin wakeup trigger wakeirq ? note: the gie bit must enable during all interrupt operation.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 58 version 1.0 6.2 inten interrupt enable register inten is the interrupt request control register including one internal interrupts, one exte rnal interrupts enable control bits. one of the register to be set ?1? is to enable the interrupt request function. once of the interrupt occur, the stack is incremented and program jump to org 8 to execute interrupt service routines. t he program exits the interrupt service routine when the returning interrupt service routine instruction (reti) is executed. 0c9h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 inten - usbien tc0ien t0ien sioien wakeien p00ien read/write - r/w r/ w r/w r/w r/w r/w after reset - 0 0 0 0 0 0 bit 0 p00ien: external p0.0 interrupt (int0) control bit. 0 = disable int0 interrupt function. 1 = enable int0 interrupt function. bit 1 wakeien: i/o port0 & port 1 wakeup interrupt control bit. 0 = disable wakeup interrupt function. 1 = enable wakeup interrupt function. bit 3 sioien: sio interrupt control bit. 0 = disable sio interrupt function. 1 = enable sio interrupt function. bit 4 t0ien: t0 timer interrupt control bit. 0 = disable t0 interrupt function. 1 = enable t0 interrupt function. bit 5 tc0ien: tc0 timer interrupt control bit. 0 = disable tc0 interrupt function. 1 = enable tc0 interrupt function. bit 6 usbien: usb interrupt control bit. 0 = disable usb interrupt function. 1 = enable usb interrupt function.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 59 version 1.0 6.3 intrq interrupt request register intrq is the interrupt request flag register. the register incl udes all interrupt request indication flags. each one of the interrupt requests occurs; the bit of the intrq register would be set ?1?. the intrq value needs to be clear by programming after detecting the flag. in the interrupt vect or of program, users know the any interrupt requests occurring by the register and do the routi ne corresponding of the interrupt request. 0c8h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 intrq - usbirq tc0irq t0irq sioirq wakeirq p00irq read/write - r/w r/ w r/w r/w r/w r/w after reset - 0 0 0 0 0 0 bit 0 p00irq: external p0.0 interrupt (int0) request flag. 0 = none int0 interrupt request. 1 = int0 interrupt request. bit 1 wakeirq: i/o port0 & port1 wakeup interrupt request flag. 0 = none wakeup interrupt request. 1 = wakeup interrupt request. bit 3 sioirq: sio interrupt request flag. 0 = none sio interrupt request. 1 = sio interrupt request. bit 4 t0irq: t0 timer interrupt request flag. 0 = none t0 interrupt request. 1 = t0 interrupt request. bit 5 tc0irq: tc0 timer interrupt request flag. 0 = none tc0 interrupt request. 1 = tc0 interrupt request. bit 6 usbirq: usb timer interrupt request flag. 0 = none usb interrupt request. 1 = usb interrupt request. 6.4 gie global interrupt operation gie is the global interrupt control bit. all interrupts start wo rk after the gie = 1 it is necessary for interrupt service request. one of the interrupt requests occurs, and the program co unter (pc) points to the interrupt vector (org 8) and the stack add 1 level. 0dfh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stkp gie - - - - stkpb2 stkpb1 stkpb0 read/write r/w - - - - r/w r/w r/w after reset 0 - - - - 1 1 1 bit 7 gie: global interrupt control bit. 0 = disable global interrupt. 1 = enable global interrupt. example: set global interrupt control bit (gie). b0bset fgie ; enable gie ? note: the gie bit must enable during all interrupt operation.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 60 version 1.0 6.5 push, pop routine when any interrupt occurs, system will jump to org 8 and ex ecute interrupt service routine. it is necessary to save acc, pflag data. the chip includes ?pus h?, ?pop? for in/out interrupt service r outine. the two instructions save and load acc , pflag data into buffers and avoid main routine erro r after interrupt service routine finishing. ? note: ?push?, ?pop? instructions save and load a cc/pflag without (nt0, npd). push/pop buffer is an unique buffer and only one level. ? example: store acc and paflg data by push, po p instructions when interrupt service routine executed. org 0 jmp start org 8 jmp int_service org 10h start: ? int_service: push ; save acc and pflag to buffers. ? ? pop ; load acc and pflag from buffers. reti ; exit interrupt service vector ? endp
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 61 version 1.0 6.6 int0 (p0.0) interrupt operation when the int0 trigger occurs, the p00irq will be set to ?1 ? no matter the p00ien is enable or disable. if the p00ien = 1 and the trigger event p00irq is also set to be ?1?. as t he result, the system will execute the interrupt vector (org 8). if the p00ien = 0 and the trigger event p00irq is still se t to be ?1?. moreover, the sy stem won?t execute interrupt vector even when the p00irq is set to be ?1?. users need to be cautious with the operation under multi-interrupt situation. if the interrupt trigger direction is identical with wake-up tr igger direction, the int0 inte rrupt request flag (int0irq) is latched while system wake-up from power down mode or gr een mode by p0.0 wake-up trigger. system inserts to interrupt vector (org 8) after wake-up immediately. ? note: int0 interrupt request can be latched by p0.0 wake-up trigger. ? note: the interrupt trigger direction of p0.0 is control by pedge register. 0bfh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pedge - - - p00g1 p00g0 - - - read/write - - - r/w r/w - - - after reset - - - 1 0 - - - bit[4:3] p00g[1:0]: p0.0 interrupt trigger edge control bits. 00 = reserved. 01 = rising edge. 10 = falling edge. 11 = rising/falling bi-direction (level change trigger). example: setup int0 interrupt request and bi-direction edge trigger. mov a, #18h b0mov pedge, a ; set int0 interr upt trigger as bi-direction edge. b0bset fp00ien ; enable int0 interrupt service b0bclr fp00irq ; clear int0 interrupt request flag b0bset fgie ; enable gie
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 62 version 1.0 example: int0 interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: ? ; push routine to save acc and pflag to buffers. b0bts1 fp00irq ; check p00irq jmp exit_int ; p00irq = 0, exit interrupt vector b0bclr fp00irq ; reset p00irq ? ; int0 interrupt service routine ? exit_int: ? ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 63 version 1.0 6.7 t0 interrupt operation when the t0c counter occurs overflow, the t0irq will be se t to ?1? however the t0ien is enable or disable. if the t0ien = 1, the trigger event will make the t0irq to be ?1? a nd the system enter interrupt ve ctor. if the t0ien = 0, the trigger event will make the t0irq to be ?1? but the system will not enter interr upt vector. users need to care for the operation under multi-interrupt situation. ? example: t0 interrupt request setup. b0bclr ft0ien ; disable t0 interrupt service b0bclr ft0enb ; disable t0 timer mov a, #20h ; b0mov t0m, a ; set t0 clock = fcpu / 64 mov a, #74h ; set t0c initial value = 74h b0mov t0c, a ; set t0 interval = 10 ms b0bset ft0ien ; enable t0 interrupt service b0bclr ft0irq ; clear t0 interrupt request flag b0bset ft0enb ; enable t0 timer b0bset fgie ; enable gie example: t0 interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: ? ; push routine to save acc and pflag to buffers. b0bts1 ft0irq ; check t0irq jmp exit_int ; t0irq = 0, exit interrupt vector b0bclr ft0irq ; reset t0irq mov a, #74h b0mov t0c, a ; reset t0c. ? ; t0 interrupt service routine ? exit_int: ? ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 64 version 1.0 6.8 tc0 interrupt operation when the tc0c counter overflows, the tc0irq will be set to ?1? no matter the tc0ien is enable or disable. if the tc0ien and the trigger event tc0irq is set to be ?1?. as t he result, the system will execute the interrupt vector. if the tc0ien = 0, the trigger event tc0irq is still set to be ?1?. moreover, the system won?t execute interrupt vector even when the tc0ien is set to be ?1?. users need to be cautio us with the operation under multi-interrupt situation. ? example: tc0 interrupt request setup. b0bclr ftc0ien ; disable tc0 interrupt service b0bclr ftc0enb ; disable tc0 timer mov a, #20h ; b0mov tc0m, a ; set tc0 clock = fcpu / 64 mov a, #74h ; set tc0c initial value = 74h b0mov tc0c, a ; set tc0 interval = 10 ms b0bset ftc0ien ; enable tc0 interrupt service b0bclr ftc0irq ; clear tc0 interrupt request flag b0bset ftc0enb ; enable tc0 timer b0bset fgie ; enable gie example: tc0 interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: ? ; push routine to save acc and pflag to buffers. b0bts1 ftc0irq ; check tc0irq jmp exit_int ; tc0irq = 0, exit interrupt vector b0bclr ftc0irq ; reset tc0irq mov a, #74h b0mov tc0c, a ; reset tc0c. ? ; tc0 interrupt service routine ? exit_int: ? ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 65 version 1.0 6.9 usb interrupt operation when the usb process finished, the usbirq will be set to ?1? no matter the usbien is enable or disable. if the usbien and the trigger event usbirq is set to be ?1?. as the result, the system will exec ute the interrupt vector. if the usbien = 0, the trigger event usbirq is still set to be ?1?. moreover, the system won?t execute interrupt vector. users need to be cautious with the opera tion under multi-interrupt situation. ? example: usb interrupt request setup. b0bclr fusbien ; disable usb interrupt service b0bclr fusbirq ; clear usb interrupt request flag b0bset fusbien ; enable usb interrupt service ? ; usb initialize. ? ; usb operation. b0bset fgie ; enable gie example: usb interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: push ; push routine to save acc and pflag to buffers. b0bts1 fusbirq ; check usbirq jmp exit_int ; usbirq = 0, exit interrupt vector b0bclr fusbirq ; reset usbirq ? ; usb interrupt service routine ? exit_int: pop ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 66 version 1.0 6.10 wakeup interrupt operation when the i/o port 1 or i/o port 0 wakeup the mcu from the sleep mode, the wakeirq will be set to ?1? no matter the wakeien is enable or disable. if the w akeien and the trigger event wakeirq is set to be ?1?. as the result, the system will execute the interr upt vector. if the wakeien = 0, the trigger event wakeir q is still set to be ?1?. moreover, the system won?t execute inte rrupt vector. users need to be cautious with the operation under multi-interrupt situation. ? example: wake interrupt request setup. b0bclr fwakeien ; disable wake interrupt service b0bclr fwakeirq ; clear wake interrupt request flag b0bset fwakeien ; enable wake interrupt service ? ; pin wakeup initialize. ? ; pin wakeup operation. b0bset fgie ; enable gie example: wake interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: push ; push routine to save acc and pflag to buffers. b0bts1 fwakeirq ; check wakeirq jmp exit_int ; wakeirq = 0, exit interrupt vector b0bclr fwakeirq ; reset wakeirq ? ; wake interrupt service routine ? exit_int: pop ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 67 version 1.0 6.11 sio interrupt operation when the sio converting successfully, t he sioirq will be set to ?1? no matter t he sioien is enable or disable. if the sioien and the trigger event sioirq is set to be ?1?. as t he result, the system will execute the interrupt vector. if the sioien = 0, the trigger event sioirq is still set to be ?1?. moreover, t he system won?t execute interrupt vector even when the sioien is set to be ?1?. users need to be cauti ous with the operation under multi-interrupt situation. ? example: sio interrupt request setup. b0bset fsioien ; enable sio interrupt service b0bclr fsioirq ; clear sio interrupt request flag b0bset fgie ; enable gie ? example: sio interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: ? ; push routine to save acc and pflag to buffers. b0bts1 fsioirq ; check sioirq jmp exit_int ; sioirq = 0, exit interrupt vector b0bclr fsioirq ; reset sioirq ? ; sio interrupt service routine ? exit_int: ? ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 68 version 1.0 6.12 multi-interrupt operation under certain condition, the software designer uses more than one interrupt requests. processing multi-interrupt request requires setting the priority of the interrupt requests. the irq flags of interrupts are controlled by the interrupt event. nevertheless, the irq flag ?1? doesn?t mean the syst em will execute the interrupt vector. in addition, which means the irq flags can be set ?1? by the events without enable the interrupt. once the event occurs, the irq will be logic ?1?. the irq and its trigger event relationship is as the below table. interrupt name trigger event description p00irq p0.0 trigger controlled by pedge t0irq t0c overflow tc0irq tc0c overflow usbirq usb process finished waekirq i/o port0 & port1 wakeup mcu sioirq sio process finished for multi-interrupt conditions, two things need to be taking care of. one is to set the priority for these interrupt requests. two is using ien and irq flags to decide which interrupt to be executed. users have to check interrupt control bit and interrupt request flag in interrupt routine. ? example: check the interrupt request under multi-interrupt operation org 8 ; interrupt vector jmp int_service int_service: ? ; push routine to save acc and pflag to buffers. intp00chk: ; check int0 interrupt request b0bts1 fp00ien ; check p00ien jmp intt0chk ; jump check to next interrupt b0bts0 fp00irq ; check p00irq jmp intp00 intt0chk: ; check t0 interrupt request b0bts1 ft0ien ; check t0ien jmp inttc0chk ; jump check to next interrupt b0bts0 ft0irq ; check t0irq jmp intt0 ; jump to t0 interrupt service routine inttc0chk: ; check tc0 interrupt request b0bts1 ftc0ien ; check tc0ien jmp inttc1chk ; jump check to next interrupt b0bts0 ftc0irq ; check tc0irq jmp inttc0 ; jump to tc0 interrupt service routine intusbchk: ; check usb interrupt request b0bts1 fusbien ; check usbien jmp intwakechk ; jump check to next interrupt b0bts0 fusbirq ; check usbirq jmp intusb ; jump to usb interrupt service routine intwakechk: ; check usb interrupt request b0bts1 fwakeien ; check wakeien jmp intsiochk ; jump check to next interrupt b0bts0 fwakeirq ; check wakeirq jmp intwakeup ; jump to wakeu p interrupt service routine intsiochk: ; check sio interrupt request b0bts1 fsioien ; check sioien jmp int_exit ; jump check to next interrupt b0bts0 fsioirq ; check sioirq jmp intsio ; jump to sio interrupt service routine int_exit: ? ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 69 version 1.0 7 i/o port 7.1 i/o port mode the port direction is programmed by pnm register. a ll i/o ports can select input or output direction. 0b8h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p0m - - p05m p04m p03m p02m p01m p00m read/write - - r r/w r/w r/w r/w r/w after reset - - 0 0 0 0 0 0 0c1h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p1m p17m p16m p15m p14m p13m p12m p12m p10m read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 0c5h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p5m - - - - - p52m p51m p50m read/write - - - - - r/w r/w r/w after reset - - - - - 0 0 0 bit[7:0] pnm[7:0]: pn mode control bits. (n = 0~5). 0 = pn is input mode. 1 = pn is output mode. ? note: 1. users can program them by bit c ontrol instructions (b0bset, b0bclr). 2. p0.5 is input only pin, so there is no p0.5 mode control bit. ? example: i/o mode selecting clr p0m ; set all ports to be input mode. clr p1m clr p5m mov a, #0ffh ; set all ports to be output mode. b0mov p0m, a b0mov p1m, a b0mov p5m, a b0bclr p1m.2 ; set p1.2 to be input mode. b0bset p1m.2 ; set p1.2 to be output mode.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 70 version 1.0 7.2 i/o pull up register 0e0h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p0ur - p04r p03r p02r p01r p00r read/write - w w w w w after reset - 0 0 0 0 0 0e1h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p1ur p17r p16r p15r p16r p13r p12r p11r p10r read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 0e5h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p5ur p52r p51r p50r read/write w w w after reset 0 0 0 ? note: p0.5 is input only pin without pull-up resister, so there is no p0.5 pull-up resistor control bit. ? note: when set p0.5 to input mode, please add the series external 100 ohm on it. ? example: i/o pull up register mov a, #0ffh ; enable port0, 1, 5 pull-up register, b0mov p0ur, a ; b0mov p1ur, a b0mov p5ur, a
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 71 version 1.0 7.3 i/o open-drain register p1.0/p1.1 is built-in open-drain function. p1.0/p1.1 mu st be set as output mode when enable p1.0/p1.1 open-drain function. open-drain external circuit is as following. u mcu2 u vcc open-drain pin open-drain pin mcu1 pull-up resistor the pull-up resistor is necessary. open-drain output high is driven by pull-up resistor. output low is sunken by mcu?s pin. ? note: p1.0/p1.1 open-drain function can be 2 nd ps/2 interface on chip. more detail information refer to ps/2 chapter. 0e9h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p1oc - - - - p52oc p50oc p11oc p10oc read/write - - - - w w w w after reset - - - - 0 0 0 0 bit [1:0] p1noc: port 1 open-drain control bit 0 = disable open-drain mode 1 = enable open-drain mode bit [3:2] p5noc: port 5 open-drain control bit 0 = disable open-drain mode 1 = enable open-drain mode ? example: enable p1.0 to open-drain mode and output high. b0bset p1.0 ; set p1.0 buffer high. b0bset p10m ; enable p1.0 output mode. mov a, #01h ; enable p1.0 open-drain function. b0mov p1oc, a ? note: p1oc is a write only register. setting p10oc must be used ?mov? instructions. ? example: disable p1.0 to open-drain mode and output low. mov a, #0xe ; disable p1.0 open-drain function. b0mov p1oc, a ? note: after disable p1.0 open-drain function, p1.0 mode returns to last i/o mode.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 72 version 1.0 7.4 i/o port data register 0d0h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p0 - p05 p04 p03 p02 p01 p00 read/write - r r/w r/w r/w r/w r/w after reset - 0 0 0 0 0 0 0d1h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p1 p17 p16 p15 p14 p13 p12 p11 p10 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 0d5h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p5 p52 p51 p50 read/write r/w r/w r/w after reset 0 0 0 ? note: the p05 keeps ?1? when external reset enable by code option. ? example: read data from input port. b0mov a, p0 ; read data from port 0 b0mov a, p1 ; read data from port 1 b0mov a, p5 ; read data from port 5 ? example: write data to output port. mov a, #0ffh ; write data ffh to all port. b0mov p0, a b0mov p1, a b0mov p5, a ? example: write one bit data to output port. b0bset p1.3 ; set p1.3 and p5.5 to be ?1?. b0bset p5.5 b0bclr p1.3 ; set p1.3 and p5.5 to be ?0?. b0bclr p5.5 7.5 i/o port1 wakeup control register 0d0h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p1w p17w p16w p15w p14w p13w p12w p11w p10w read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit [7:0] p1nw: port 1 wakeup function control bit 0 = disable port 1 wakeup function 1 = enable port 1 wakeup function
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 73 version 1.0 8 timers 8.1 watchdog timer the watchdog timer (wdt) is a binary up counter designed for monitoring program execution. if the program goes into the unknown status by noise interferen ce, wdt overflow signal raises and resets mcu. watchdog clock controlled by code option and the clock source is internal low-speed oscillator (16khz @3v, 32khz @5v). watchdog overflow time = 8192 / inte rnal low-speed oscillator (sec). vdd internal low rc freq. watchdog overflow time 3v 16khz 512ms 5v 32khz 256ms ? note: if watchdog is ?always_on? mode, it keeps running event under power down mode or green mode. watchdog clear is controlled by wdtr register. moving 0x5a data into wdtr is to reset watchdog timer. 0cch bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 wdtr wdtr7 wdtr6 wdtr5 wdtr4 wdtr3 wdtr2 wdtr1 wdtr0 read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 example: an operation of watchdog timer is as following. to clear the watchdog timer counter in the top of the main routine of the program. main: mov a,#5ah ; clear the watchdog timer. b0mov wdtr,a ? call sub1 call sub2 ? ? ? jmp main
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 74 version 1.0 watchdog timer application note is as following. z before clearing watchdog timer, check i/o status and check ram contents c an improve system error. z don?t clear watchdog timer in interrupt vector and interrupt service routine. that can improve main routine fail. z clearing watchdog timer program is only at one part of the program. this way is the best structure to enhance the watchdog timer function. ? example: an operation of watchdog timer is as following. to clear the watchdog timer counter in the top of the main routine of the program. main: ? ; check i/o. ? ; check ram err: jmp $ ; i/o or ram error. program jump here and don?t ; clear watchdog. wait watchdog timer overflow to reset ic. correct: ; i/o and ram are correct. clear watchdog timer and ; execute program. b0bset fwdrst ; only one clearing watchdog timer of whole program. ? call sub1 call sub2 ? ? ? jmp main
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 75 version 1.0 8.2 timer 0 (t0) 8.2.1 overview the t0 is an 8-bit binary up timer and event counter. if t0 ti mer occurs an overflow (from ffh to 00h), it will continue counting and issue a time-out signal to trigger t0 interrupt to request interrupt service. the main purpose of the t0 timer is as following. ) 8-bit programmable up counting timer: generates interrupts at specific time intervals based on the selected clock frequency. ) green mode wakeup function: t0 can be green mode wake -up time as t0enb = 1. system will be wake-up by t0 time out. fcpu t0 rate (fcpu/2~fcpu/256) t0enb cpum0,1 t0c 8-bit binary up counting counter t0 time out load internal data bus 8.2.2 t0m mode register 0d8h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 t0m t0enb t0rate2 t0rate1 t0rate0 - - - read/write r/w r/w r/w r/w - - - after reset 0 0 0 0 - - - bit [6:4] t0rate[2:0]: t0 internal clock select bits. 000 = fcpu/256. 001 = fcpu/128. ? 110 = fcpu/4. 111 = fcpu/2. bit 7 t0enb: t0 counter control bit. 0 = disable t0 timer. 1 = enable t0 timer.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 76 version 1.0 8.2.3 t0c counting register t0c is an 8-bit counter register for t0 interval time control. 0d9h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 t0c t0c7 t0c6 t0c5 t0c4 t0c3 t0c2 t0c1 t0c0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 the equation of t0c initial value is as following. t0c initial value = 256 - (t0 interrupt interval time * input clock) example: to set 1ms interval time for t0 interrupt . high clock is 12mhz. fcpu=fosc/2. select t0rate=010 (fcpu/64). t0c initial value = 256 - (t0 interrupt interval time * input clock) = 256 - (1ms * 6mhz / 1 / 64) = 256 - (10 -3 * 6 * 10 6 / 1 / 64) = 162 = a2h the basic timer table interval time of t0. high speed mode (fcpu = 12mhz / 2) t0rate t0clock max overflow interval one step = max/256 000 fcpu/256 10.923 ms 42.67 us 001 fcpu/128 5.461 ms 21.33 us 010 fcpu/64 2.731 ms 10.67 us 011 fcpu/32 1.365 ms 5.33 us 100 fcpu/16 0.683 ms 2.67 us 101 fcpu/8 0.341 ms 1.33 us 110 fcpu/4 0.171 ms 0.67 us 111 fcpu/2 0.085 ms 0.33 us
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 77 version 1.0 8.2.4 t0 timer operation sequence t0 timer operation sequence of setup t0 timer is as following. ) stop t0 timer counting, disable t0 interrupt function and clear t0 interrupt request flag. b0bclr ft0enb ; t0 timer. b0bclr ft0ien ; t0 interrupt function is disabled. b0bclr ft0irq ; t0 interrupt request flag is cleared. ) set t0 timer rate. mov a, #0xxx0000b ;the t0 rate control bi ts exist in bit4~bit6 of t0m. the ; value is from x000xxxxb~x111xxxxb. b0mov t0m,a ; t0 timer is disabled. ) set t0 interrupt interval time. mov a,#7fh b0mov t0c,a ; set t0c value. ) set t0 timer function mode. b0bset ft0ien ; enable t0 interrupt function. ) enable t0 timer. b0bset ft0enb ; enable t0 timer.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 78 version 1.0 8.3 timer c0 (tc0) 8.3.1 overview the tc0 is an 8-bit binary up timer and event counter. if tc 0 timer occurs an overflow (from ffh to 00h), it will continue counting and issue a time-out signal to trig ger tc0 interrupt to request interrupt service. the main purpose of the tc0 timer is as following. ) 8-bit programmable up counting timer: generates interrupts at specific time intervals based on the selected clock frequency. ) green mode wakeup function: tc0 can be green mode wake-up time as tc0enb = 1. system will be wake-up by tc0 time out. fcpu tc0 rate (fcpu/2~fcpu/256) tc0enb cpum0,1 tc0c 8-bit binary up counting counter tc0 time out load internal data bus 8.3.2 tc0m mode register 0dah bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc0m tc0enb tc0rate2 tc0rate1 tc0rate0 - - - read/write r/w r/w r/w r/w - - - after reset 0 0 0 0 - - - bit [6:4] tc0rate[2:0]: tc0 internal clock select bits. 000 = fcpu/256. 001 = fcpu/128. ? 110 = fcpu/4. 111 = fcpu/2. bit 7 tc0enb: tc0 counter control bit. 0 = disable tc0 timer. 1 = enable tc0 timer.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 79 version 1.0 8.3.3 tc0c counting register tc0c is an 8-bit counter register for tc0 interval time control. 0dbh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc0c tc0c7 tc0c6 tc0c5 tc0c4 tc0c3 tc0c2 tc0c1 tc0c0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 the equation of tc0c initial value is as following. tc0c initial value = 256 - (tc0 interrupt interval time * input clock) example: to set 1ms interval time for tc0 interrupt. high clock is 12mhz. fcpu=fosc/2. select tc0rate=010 (fcpu/64). tc0c initial value = 256 - (tc0 interrupt interval time * input clock) = 256 - (1ms * 6mhz / 1 / 64) = 256 - (10 -3 * 6 * 10 6 / 1 / 64) = 162 = a2h the basic timer table interval time of tc0. high speed mode (fcpu = 12mhz / 2) tc0rate tc0clock max overflow interval one step = max/256 000 fcpu/256 10.923 ms 42.67 us 001 fcpu/128 5.461 ms 21.33 us 010 fcpu/64 2.731 ms 10.67 us 011 fcpu/32 1.365 ms 5.33 us 100 fcpu/16 0.683 ms 2.67 us 101 fcpu/8 0.341 ms 1.33 us 110 fcpu/4 0.171 ms 0.67 us 111 fcpu/2 0.085 ms 0.33 us 8.3.4 tc0 timer operation sequence tc0 timer operation sequence of setup tc0 timer is as following. ) stop tc0 timer counting, disable tc0 interrupt function and clear tc0 interrupt request flag. b0bclr ftc0enb ; tc0 timer. b0bclr ftc0ien ; tc0 inte rrupt function is disabled. b0bclr ftc0irq ; tc0 interrupt request flag is cleared. ) set tc0 timer rate. mov a, #0xxx0000b ;the tc0 rate control bi ts exist in bit4~bit6 of tc0m. the ; value is from x000xxxxb~x111xxxxb. b0mov tc0m,a ; tc0 timer is disabled. ) set tc0 interrupt interval time.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 80 version 1.0 mov a,#7fh b0mov tc0c,a ; set tc0c value. ) set tc0 timer function mode. b0bset ftc0ien ; enable tc0 interrupt function. ) enable tc0 timer. b0bset ftc0enb ; enable tc0 timer.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 81 version 1.0 9 universal serial bus (usb) 9.1 overview the usb is the answer to connectivity for the pc architectu re. a fast, bi-directional, isochronous, low-cost, dynamically attachable serial interface is consistent with the require ments of the pc platform of today and tomorrow. the sonix usb microcontrollers are optimized for human-interface co mputer peripherals such as a mouse, joystick, and game pad. usb specification compliance ? conforms to usb specifications, version 2.0. ? conforms to usb hid specification, version 1.11. ? supports 1 full-speed usb device address. ? supports 1 control endpoint and 2 interrupt endpoints. ? integrated usb transceiver. ? 5v to 3.3v regulator output for d+ resistor pull up. 9.2 usb machine the usb machine allows the microcontroller to communica te with the usb host. the hardware handles the following usb bus activity independently of the microcontroller. the usb machine will do: ? translate the encoded received data and form at the data to be transmitted on the bus. ? crc checking and generation by hardw are. if crc is not correc t, hardware will not send any response to usb host. ? send and update the data toggle bit (dat a1/0) automatically by hardware. ? send appropriate ack/nak/stall handshakes. ? setup, in, or out token type identification. set t he appropriate bit once a valid token is received. ? place valid received data in the appropriate endpoint fifos. ? bit stuffing/unstuffing. ? address checking. ignore the transa ctions not addressed to the device. ? endpoint checking. check the endpoint?s request from usb host, and set the appropriate bit of registers. firmware is required to handle the rest of the following tasks: ? coordinate enumeration by decoding usb device requests. ? fill and empty the fifos. ? suspend/resume coordination. ? remote wake up function. ? determine the right interrupt request of usb communication.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 82 version 1.0 9.3 usb interrupt the usb function will accept the usb host command and generate the relative interrupts, and the program counter will go to 0x08 vector. firmware is required to check the usb st atus bit to realize what r equest comes from the usb host. the usb function interrupt is generated when: ? the endpoint 0 is set to accept a setup token. ? the device receives an ack handshake after a succ essful read transaction (in) from the host. ? if the endpoint is in ack out modes, an inte rrupt is generated when data is received. ? the usb host send usb suspend request to the device. ? usb bus reset event occurs. ? the usb endpoints interrupt after a usb transaction complete is on the bus. ? the usb resume when the usb bus is placed in the suspend state. the following examples show how to avoid the error of reading or writing the endpoint fifos and to do the right usb request routine according to the flag. example: save the udp0, udp1, acc and status flag when interrupt request occurs. to avoid the error when read or write data in the endpoints fifos. org 0x8 push ; save acc and status flag mov a, udp0 ; save the udp0 register value to udp0_temp mov udp0_temp, a mov a, udp1 ; save the udp1 register value to udp1_temp mov udp1_temp, a ? ? mov a, udp0_temp mov udp0, a ; load the udp0_temp register value to udp0 mov a, udp1_temp mov udp1, a ; load the udp1_temp register value to udp1 pop ; load the acc and status flag reti example: defining usb interrupt request. the interrupt service routine is following org 8. org 0x8 b0bts0 ustatus.6 ; check usb bus reset request jmp _usb_bus_reset ; jump to usb bus reset routine b0bts0 ustatus.5 ; check usb suspend request jmp _usb_suspend ; jump to usb suspend routine b0bts0 ustatus.4 ; check ep0 setup token jmp _ep0_setup ; jump to ep0 setup token routine.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 83 version 1.0 b0bts0 ustatus.3 ; check ep0 in token jmp _ep0_in ; jump to ep0 in routine. b0bts0 ustatus.2 ; check ep0 out token. jmp _ep0_out ; jump to ep0 out routine. b0bts0 ustatus.1 ; check ep1?s transaction is completed jmp _ep1_ack ; jump to ep1?s transaction routine. b0bts0 ustatus.0 ; check ep2?s transaction is completed jmp _ep2_ack ; jump to ep2?s transaction routine. reti 9.4 usb enumeration a typical usb enumeration sequence is shown below. 1. the host computer sends a setup packet followed by a data packet to usb address 0 requesting the device descriptor. 2. firmware decodes the request and retrieves its de vice descriptor from the program memory tables. 3. the host computer performs a control read sequence and firmware responds by sending the device descriptor over the usb bus, via the on-chip fifo. 4. after receiving the descriptor, the host sends a setup packet followed by a data packet to address 0 assigning a new usb address to the device. 5. firmware stores the new address in its usb device address register after t he no-data control sequence completes. 6. the host sends a request for the devi ce descriptor using the new usb address. 7. firmware decodes the request and retrieves the device descriptor from program memory tables. 8. the host performs a control read sequence and firmware responds by sending its device descriptor over the usb bus. 9. the host generates control reads from the device to request the configuration and report descriptors. 10. once the device receives a set configurat ion request, its functions may now be used. 11. firmware should take appropriate action for endpoint 1~2 transactions, which may occur from this point. 9.5 usb registers 9.5.1 usb device address register the usb device address register (uda) contains a 7-bit usb device address and one bit to enable the usb function. this register is cleared during a reset, setting the usb device address to zero and disable the usb function. 0a0h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 uda ude uda6 uda5 uda4 uda3 uda2 uda1 uda0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 84 version 1.0 bit [6:0] uda [6:0]: these bits must be set by firmware during the usb enumeration process (i.e., setaddress) to the non-zero address assigned by the usb host. bit 7 ude: device function enable. this bit must be enabled by firmware to enable the usb device function. after the bit is set, the d- will pull up automatically to indicate the low speed device to the usb host. 0 = disable usb device function. 1 = enable usb device function. 9.5.2 usb status register the usb status register indicates the status of usb. 0a1h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ustatus bus_rst suspend ep0_setup ep0_in ep0_out ep1 ack ep2 ack read/write r r r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 bit 0 ep2_ack : endpoint 2?s ack transaction. the bit is set wh enever the endpoint 2 that completes with an ack packet. 0 = the endpoint 2?s transaction doesn?t complete with an ack. 1 = the endpoint 2?s transaction complete with an ack. bit 1 ep1_ack : endpoint 1?s ack transaction. the bit is set wh enever the endpoint 1 that completes with an ack packet. 0 = the endpoint 1?s transaction doesn?t complete with an ack. 1 = the endpoint 1?s transaction complete with an ack. bit 2 ep0_out : endpoint 0 out token received. 0 = endpoint 0 has no out token received. 1 = a valid out packet has been received. the bit is se t to 1 after the last received packet in an out transaction. bit 3 ep0_in : endpoint 0 in token received. 0 = endpoint 0 has no in token received. 1 = a valid in packet has been received. the bit is se t to 1 after the last received packet in an in transaction. bit 4 ep0_setup : endpoint 0 setup token received. 0 = endpoint 0 has no setup token received. 1 = a valid setup packet has been received. the bit is set to 1 after the last received packet in an setup transaction. while the bit is set to 1, the host can not write any data in to ep0 fifo. this prevents sie from overwriting an incoming setup transaction befor e firmware has a chance to read the setup data.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 85 version 1.0 bit 5 suspend: indicate usb suspend status. 0 = non-suspend status. when mcu wakeup from sleep mode by usb resume wakeup request, the bit will changes from 1 to 0 automatically. 1 = set to 1 by hardware when usb suspend request. bit 6 bus_rst: usb bus reset. 0 = non-usb bus reset. 1 = set to 1 by hardware when usb bus reset request. 9.5.3 usb data count register the usb fifo selection bits and usb ep0 out token data counter. 0a2h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 uctrl ffs2 ffs1 ffs0 uep0oc4 u ep0oc3 uep0oc2 u ep0oc1 uep0oc0 read/write r r r r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit [4:0] uep0c [4:0]: usb endpoint 0 out token data counter. bit 5 ffs0: endpoint 0 fifo selection control bit. ffs0 endpoint 0 out data endpoint 0 in data 0 fifo 1 fifo 0 1 fifo 0 fifo 1 bit 6 ffs1: endpoint 1 fifo selection control bit. ffs0 endpoint 1 out data endpoint 1 in data 0 fifo 1 fifo 0 1 fifo 0 fifo 1 bit 7 ffs2: endpoint 2 fifo selection control bit. ffs0 endpoint 2 out data endpoint 2 in data 0 fifo 1 fifo 0 1 fifo 0 fifo 1 9.5.4 usb endpoint 0 enable register an endpoint 0 (ep0) is used to initialize and control the usb dev ice. ep0 is bi-directional (control pipe), as the device, can both receive and transmit data, whic h provides to access the device configuration information and allows generic usb status and control accesses. 0a3h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ue0r - ue0m1 ue0m0 - ue 0c3 ue0c ue0c1 ue0c0 read/write - r/w r/ w - r/w r/w r/w r/w after reset - 0 0 - 0 0 0 0 bit [3:0] ue0c [3:0]: indicate the number of data bytes in a transac tion: for in transactions, firmware loads the count with the number of bytes to be transmi tted to the host from the endpoint 0 fifo.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 86 version 1.0 bit [6:5] ue0m [1:0]: the endpoint 0 modes determine how the sie responds to usb traffic that the host sends to the endpoint 0. for example, if the endpoi nt 0?s mode bit is set to 00 that is nak in/out mode as shown in table, the usb sie will send nak handshakes in response to any in/out token set to the endpoint 0. usb endpoint 0?s mode table ue0m1 ue0m0 in/out token handshake 0 0 nak 0 1 ack 1 0 stall 1 1 stall 9.5.5 usb endpoint 1 enable register the communication with the usb host using endpoint 1, endpoi nt 1?s fifo is implemented as 16 bytes of dedicated ram. the endponit1 is an interrupt endpoint. 0a4h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ue1r ue1e ue1m1 ue1m0 ue1c 4 ue1c3 ue1c ue1c1 ue1c0 read/write r/w r r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit [4:0] ue1c [4:0]: indicate the number of data bytes in a transac tion: for in transactions, firmware loads the count with the number of bytes to be transmi tted to the host from the endpoint 1 fifo. bit [6:5] ue1m [1:0]: the endpoint 1 modes determine how the sie responds to usb traffic that the host sends to the endpoint 1. for example, if the endpoi nt 1?s mode bit is set to 00 that is nak in/out mode as shown in table, the usb sie will send nak handshakes in response to any in/out token set to the endpoint 1. usb endpoint 1?s mode table ue1m1 ue1m0 in/out token handshake 0 0 nak 0 1 ack 1 0 stall 1 1 stall bit 7 ue1e: usb endpoint 1 function enable bit. 0 = disable usb endpoint 1 function. 1 = enable usb endpoint 1 function.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 87 version 1.0 the following examples show how to do the right us b endpoints request routine according to the flag. example: check the endpoint 1?s in/out request _ ep1_check: b0bts0 ustatus.1 ;check if endpoint 1 transaction is completed. call _ep1_function jmp _ep1_check _ep1_function: write_ep1: ep1_wr_ram_addr_set #0x8 ;set endpoint 1 fifo address ep1_wr_ram_data ep1_data ;write ep1_data to usb fifo. ep1_wr_ram_addr_add #0x1 ;fifo address + 1 ep1_wr_ram_data mo use_x_axis ;write mo use_x_axis to fifo. ? ? mov a, #0xa8 ;1.keep enable ep1 ;2. send 8 byte to usb host ;3. ready to transfer, the ack handshake b0mov ue1e, a ret example: check the endpoint 1?s out request _ep1_check: b0bset ue1e.5 ;ready to receive data from usb host (out token) b0bts0 ustatus.1 ;check if endpoint 1 transaction is completed. call _ep1_function jmp _ep1_check _ep1_function: read_ep1: ep1_rd_ram_addr_set #0x8 ;set endpoint 1 fifo address ep1_rd_ram_data ;data move to acc mov fifo_data_0, a ;data move to fifo_data_0 ep1_rd_ram_addr_add #0x1 ;fifo address + 1 ep1_rd_ram_data ;data move to acc ret
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 88 version 1.0 9.5.6 usb endpoint 2 enable register the communication with the usb host using endpoint 2, endpoi nt 2?s fifo is implemented as 16 bytes of dedicated ram. the endpoint 2 is an interrupt endpoint. 0a5h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ue2r ue2e ue2m1 ue2m0 ue2c 4 ue2c3 ue2c ue2c1 ue2c0 read/write r/w r r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit [4:0] ue2c [4:0]: indicate the number of data bytes in a transac tion: for in transactions, firmware loads the count with the number of bytes to be transmi tted to the host from the endpoint 2 fifo. bit [6:5] ue2m [1:0]: the endpoint 2 modes determine how the sie responds to usb traffic that the host sends to the endpoint 2. for example, if the endpoi nt 2?s mode bit is set to 00 that is nak in/out mode as shown in table, the usb sie will send nak handshakes in response to any in/out token set to the endpoint 2. usb endpoint 2?s mode table ue2m1 ue2m0 in/out token handshake 0 0 nak 0 1 ack 1 0 stall 1 1 stall bit 7 ue2e: usb endpoint 2 function enable bit. 0 = disable usb endpoint 2 function. 1 = enable usb endpoint 2 function. 9.5.7 usb data pointer 0 register fifo 0?s address pointer. use the point to set the fifo address for reading data from fifo and writing data to fifo. 0a6h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 udp0 udp05 udp04 udp03 udp02 udp01 udp00 read/write - - r/w r/w r/w r/w r/w r/w after reset - - 0 0 0 0 0 0 address [07]~address [00]: data buffer for endpoint 0. check t he bit 5 of the uctrl register (0xa2h) to select the right fifo. address [17]~address [08]: data buffer for endpoint 1. check t he bit 6 of the uctrl register (0xa2h) to select the right fifo. address [27]~address [18]: data buffer for endpoint 2. check t he bit 7 of the uctrl register (0xa2h) to select the right fifo.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 89 version 1.0 the following examples show how to do select the right fifo address pointer. example 1. set endpoint 0?s fifo addr ess, when reading data from fifo. ep0_fifo_read_address: b0bts0 uctrl.5 jmp udp0_address_set ;go to set the udp0 address jmp udp1_address_set ;go to set the udp1 address udp0_address_set: mov a, address mov udp0, a jmp user_define_routine udp1_address_set: mov a, address mov udp1, a jmp user_define_routine example 2. read data from ep0 fifo. ep0_fifo_rd_data: b0bts0 uctrl.5 ;check the bit to select the right fifo jmp read_endpoint0_fifo_udr0 jmp read_endpoint0_fifo_udr1 read_endpoint0_fifo_udr0: mov a, udr0 ; move fifo?s data to a jmp user_define_routine read_endpoint0_fifo_udr1: mov a, udr1 ;move fifo?s data to a jmp user_define_routine example 3. set endpoint 1?s fifo address, when writing data to fifo. ep1_fifo_write_address: b0bts1 uctrl.6 jmp udp0_address_set ;go to set the udp0 address jmp udp1_address_set ;go to set the udp1 address udp0_address_set: mov a, address ; set the address to udp. mov udp0, a
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 90 version 1.0 jmp user_define_routine udp1_address_set: mov a, address ; set the address to udp. mov udp1, a jmp user_define_routine example 4. write data to ep2 fifo. ep2_fifo_write_data: b0bts1 uctrl.7 ;check the bit to select the right fifo jmp write_endpoint2_fifo_udr0 jmp write_endpoint2_fifo_udr1 write _endpoint2_fifo_udr0 mov a, udr0 jmp user_define_routine write _endpoint2_fifo_udr1 mov a, udr1 jmp user_define_routine 9.5.8 usb data register store the data, which udp0 point to. 0a7h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 udr0 udr07 udr06 udr05 udr04 udr03 udr02 udr01 udr00 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 9.5.9 usb data pointer 1 register fifo 1?s address pointer. use the point to set the fifo address for reading data from fifo and writing data to fifo. 0a8h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 udp1 udp15 udp14 udp13 udp12 udp11 udp10 read/write - - r/w r/w r/w r/w r/w r/w after reset - - 0 0 0 0 0 0 address [07]~address [00]: data buffer for endpoint 0. check t he bit 5 of the uctrl register (0xa2h) to select the right fifo. address [17]~address [08]: data buffer for endpoint 1. check t he bit 6 of the uctrl register (0xa2h) to select the right fifo. address [27]~address [18]: data buffer for endpoint 2. check t he bit 7 of the uctrl register (0xa2h) to select the right fifo.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 91 version 1.0 9.5.10 usb data register store the data, which udp1 point to. 0a9h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 udr1 udr17 udr16 udr15 udr14 udr13 udr12 udr11 udr10 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 9.5.11 upid register forcing bits allow firmware to directly drive the d+ and d? pins. 0aah bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 upid reserved reserved - - - ubde ddp ddn read/write - - - - - w w w after reset 1 1 - - - 0 0 0 bit 0 ddn: drive d- on the usb bus. 0 = drive d- low. 1 = drive d- high. bit 1 ddp: drive d+ on the usb bus. 0 = drive d+ low. 1 = drive d+ high. bit 2 ubde: enable to direct drive usb bus. 0 = disable. 1 = enable . 9.5.12 usb endpoint 1 out token data by tes counter endpoint 1?s out token data bytes counter. 0abh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ep1out_cnt - - - uep1oc4 uep1 oc3 uep1oc2 u ep1oc1 uep1oc0 read/write - - - r/w r/w r/w r/w r/w after reset - - - 0 0 0 0 0 bit [4:0] uep1cx: bytes counter of ep1 token data. reset by firmware. 9.5.13 usb endpoint 2 out token data by tes counter endpoint 1?s out token data bytes counter. 0abh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ep2out_cnt - - - uep2oc4 uep2 oc3 uep2oc2 u ep2oc1 uep2oc0 read/write - - - r/w r/w r/w r/w r/w after reset - - - 0 0 0 0 0 bit [4:0] uep2cx: bytes counter of ep2 token data. reset by firmware.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 92 version 1.0 10 serial input/output transceiver 10.1 overview the sio (serial input/output) transceiver allows high -speed synchronous data transfer between the sn8p2212 series mcu and peripheral devices or between several sn8p2212 devices. these peripheral devices may be serial eeproms, shift registers, display drivers, etc. the sn8p2212 sio features include the following: z full-duplex, 3-wire synchronous data transfer z tx/rx or tx only mode z master (sck is clock output) or sl ave (sck is clock input) operation z msb first data transfer z so (p5.2) is programmable open-drain output pin for multiple salve devices application z two programmable bit rates (only in master mode) z end-of-transfer interrupt the siom register can control sio operating function, such as: transmit/receive, clock rate, transfer edge and starting this circuit. this sio circuit will tran smit or receive 8-bit data automatically by setting senb and start bits in siom register. the siob is an 8-bit buffer, which is design ed to store transfer data. sioc and sior are designed to generate sio?s clock source with auto-reload function. the 3-bit i/o counter can monitor the operation of sio and announce an interrupt request after transmitting/receiving 8- bit data. after transferring 8-bit data, this circuit will be disabled automatically and re-transfer data by programming siom register. siob 8-bit buffer senb, txrx so/p5.2 pin siom register sck/p5.0 pin senb si/p5.1 pin sio time out 3-bit i/o counter sckmd senb senb auto_reload sioc 8-bit binary counter sior register senb srate sckmd sedge data bus reset sck sources cpum1,0 cpum1,0 cpum1,0 siob 8-bit buffer senb, txrx so/p5.2 pin siom register sck/p5.0 pin senb si/p5.1 pin sio time out 3-bit i/o counter sckmd senb senb auto_reload sioc 8-bit binary counter sior register senb srate sckmd sedge data bus reset sck sources cpum1,0 cpum1,0 cpum1,0 sio interface circuit diagram
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 93 version 1.0 the system is single-buffered in the tran smit direction and double-buffered in t he receive direction. this means that bytes to be transmitted cannot be written to the siob data register before the entire shift cycle is completed. when receiving data, however, a received byte must be read from the siob data register before the next byte has been completely shifted in. otherwise, the first byte is lo st. following figure shows a typical sio transfer between two sn8p2212 micro-controllers. master mcu sends sck for init ial the data transfer. both master and slave mcu must work in the same clock edge direction, and then both cont rollers would send and receive data at the same time. sio data transfer diagram the sio data transfer timing as following figure: sio data transfer timing ? note: in any mode, sio always transmit data in first sck edge and receive data in second sck edge. shift data in shift data out general purpose i/o pin so (p5.2) (tx/rx = 0) bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 si (p5.1) bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 so (p5.2) (tx/rx = 1) sck (p5.0) (sedge = 1) sck (p5.0) (sedge = 0) shift register (siob) 2nd receive buffer (address = siob) internal bus read siob write siob sio master (sckmd = 0) so si sck shift register (siob) 2nd receive buffer (address = siob) internal bus read siob write siob sio slave (sckmd = 1) si so sck
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 94 version 1.0 10.2 siom mode register siom initial value = 0000 x000 0b4h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 siom senb start srate1 srate0 - sckmd sedge txrx read/write r/w r/w r/ w r/w - r/w r/w r/w after reset 0 0 0 0 - 0 0 0 bit 7 senb: sio function control bit. 0 = disable (p5.0~p5.2 is general purpose port). 1 = enable (p5.0~p5.2 is sio pins). bit 6 start: sio progress control bit. 0 = end of transfer. 1 = progressing. bit [5:4] srate1,0: sio?s transfer rate select bit. these 2-bits are workless when sckmd=1. 00 = fcpu. 01 = fcpu/32 10 = fcpu/16 11 = fcpu/8. bit 2 sckmd: sio?s clock mode select bit. 0 = internal. 1 = external. bit 1 sedge: sio?s transfer clock edge select bit. 0 = falling edge. 1 = rising edge. bit 0 txrx: sio?s transfer direction select bit. 0 = receiver only. 1 = transmitter/receiver full duplex. ? note: 1. if sckmd=1 for external clock, the sio is in slave mode. if sckmd=0 for internal clock, the sio is in master mode. 2. don?t set senb and start bits in the same time. that makes the sio function error. because sio function is shared with port5 for p5.0 as sck, p5.1 as si and p5.2 as so. the following table shown the port5[2:0] i/o mode be havior and setting when sio function enable and disable. senb=1 (sio function enable) (sckmd=1) sio source = external clock p5.0 will change to input mode automatically, no matter what p5m setting p5.0/sck (sckmd=0) sio source = internal clock p5.0 will change to output mode automatically, no matter what p5m setting p5.1/si p5.1 must be set as input mode in p5m ,or the sio function will be abnormal (txrx=1) sio = transmitter/receiver p5.2 will change to output mode automatically, no matter what p5m setting p5.2/so (txrx=0) sio = receiver only p5.2 will change to input mode automatically, no matter what p5m setting senb=0 (sio function disable) p5.0/p5.1/p5.2 port5[2:0] i/o mode are fully controlled by p5m when sio function disable
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 95 version 1.0 10.3 siob data buffer siob initial value = 0000 0000 0b6h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 siob siob7 siob6 siob5 siob4 siob3 siob2 siob1 siob0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 siob is the sio data buffer register. it stores serial i/o transmit and receive data. 10.4 sior register description sior initial value = 0000 0000 0b5h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 sior sior7 sior6 sior5 sior4 sior3 sior2 sior1 sior0 read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 the sior is designed for the sio counter to reload the count ed value when end of counting. it is like a post-scaler of sio clock source and let sio has more flexible to setti ng sck range. users can set the sior value to setup sio transfer time. to setup sior value equation to desire transfer time is as following. sck frequency = sio rate / (256 - sior) sior = 256 - ( 1 / ( sck frequency ) * sio rate ) example: setup the sio clock to be 5khz. fosc = 3.58mhz. sio?s rate = fcpu = fosc/4. sior = 256 ? (1/(5khz) * 3.58mhz/4) = 256 ? (0.0002*895000) = 256 ? 179 = 77
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 96 version 1.0 example: master, duplex transfer and transmit data on rising edge mov a,txdata ; load transmitted data into siob register. b0mov siob,a mov a,#0ffh ; set sio clock b0mov sior,a mov a,#10000001b ; setup siom and enable sio function. b0mov siom,a b0bset fstart ; start trans fer and receiving sio data. chk_end: b0bts0 fstart ; wait the end of sio operation. jmp chk_end b0mov a,siob ; save siob data into rxdata buffer. mov rxdata,a example: master, duplex transfer and transmit data on falling edge mov a,txdata ; load transmitted data into siob register. b0mov siob,a mov a,#0ffh ; set sio clock. b0mov sior,a mov a,#10000011b ; setup siom and enable sio function. b0mov siom,a b0bset fstart ; start trans fer and receiving sio data. chk_end: b0bts0 fstart ; wait the end of sio operation. jmp chk_end b0mov a,siob ; save siob data into rxdata buffer. mov rxdata,a example: master, receive only and transmit data on rising edge mov a,#0ffh ; set sio clock with auto-reload function. b0mov sior,a mov a,#10000000b ; setup siom and enable sio function. b0mov siom,a b0bset fstart ; start receiving sio data. chk_end: b0bts0 fstart ; wait the end of sio operation. jmp chk_end b0mov a,siob ; save siob data into rxdata buffer. mov rxdata,a example: master, receive only and transmit data on falling edge mov a,#0ffh ; set sio clock. b0mov sior,a mov a,#10000010b ; setup siom and enable sio function. b0mov siom,a b0bset fstart ; start receiving sio data. chk_end: b0bts0 fstart ; wait the end of sio operation. jmp chk_end b0mov a,siob ; save siob data into rxdata buffer. mov rxdata,a
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 97 version 1.0 example: slave, duplex transfer and transmit data on rising edge mov a,txdata ; load transfer data into siob register. b0mov siob,a mov a,# 10000101b ; setup siom and enable sio function. b0mov siom,a b0bset fstart ; start trans fer and receiving sio data. chk_end: b0bts0 fstart ; wait the end of sio operation. jmp chk_end b0mov a,siob ; save siob data into rxdata buffer. mov rxdata,a example: slave, duplex transfer a nd transmit data on falling edge mov a,txdata ; load transfer data into siob register. b0mov siob,a mov a,# 10000111b ; setup siom and enable sio function. b0mov siom,a b0bset fstart ; start trans fer and receiving sio data. chk_end: b0bts0 fstart ; wait the end of sio operation. jmp chk_end b0mov a,siob ; save siob data into rxdata buffer. mov rxdata,a example: slave, receive only and transmit data on rising edge mov a,# 10000100b ; setup siom and enable sio function. b0mov siom,a b0bset fstart ; start receiving sio data. chk_end: b0bts0 fstart ; wait the end of sio operation. jmp chk_end b0mov a,siob ; save siob data into rxdata buffer. mov rxdata,a example: slave, receive only and transmit data on falling edge mov a,# 10000110b ; setup siom and enable sio function. b0mov siom,a b0bset fstart ; start receiving sio data. chk_end: b0bts0 fstart ; wait the end of sio operation. jmp chk_end b0mov a,siob ; save siob data into rxdata buffer. mov rxdata,a
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 98 version 1.0 11 instruction table field mnemonic description c dc z cycle mov a,m a m - - 1 m mov m,a m a - - - 1 o b0mov a,m a m (bank 0) - - 1 v b0mov m,a m (bank 0) a - - - 1 e mov a,i a i - - - 1 b0mov m,i m i, ?m? only supports 0x80~0x87 registers (e.g. pflag,r,y,z?) - - - 1 xch a,m a m - - - 1+n b0xch a,m a m (bank 0) - - - 1+n movc r, a rom [y,z] - - - 2 adc a,m a a + m + c, if occur carry, then c=1, else c=0 1 a adc m,a m a + m + c, if occur carry, then c=1, else c=0 1+n r add a,m a ( a + m, if occur carry, then c=1, else c=0 1 i add m,a m ( a + m, if occur carry, then c=1, else c=0 1+n t b0add m,a m (bank 0) ( m (bank 0) + a, if occur carry, then c=1, else c=0 1+n h add a,i a ( a + i, if occur carry, then c=1, else c=0 1 m sbc a,m a ( a - m - /c, if occur borrow, then c=0, else c=1 1 e sbc m,a m ( a - m - /c, if occur borrow, then c=0, else c=1 1+n t sub a,m a ( a - m, if occur borrow, then c=0, else c=1 1 i sub m,a m ( a - m, if occur borrow, then c=0, else c=1 1+n c sub a,i a a - i, if occur borrow, then c=0, else c=1 1 and a,m a a and m - - 1 l and m,a m a and m - - 1+n o and a,i a a and i - - 1 g or a,m a a or m - - 1 i or m,a m a or m - - 1+n c or a,i a a or i - - 1 xor a,m a a xor m - - 1 xor m,a m a xor m - - 1+n xor a,i a a xor i - - 1 swap m a (b3~b0, b7~b4) m(b7~b4, b3~b0) - - - 1 p swapm m m(b3~b0, b7~b4) m(b7~b4, b3~b0) - - - 1+n r rrc m a rrc m - - 1 o rrcm m m rrc m - - 1+n c rlc m a rlc m - - 1 e rlcm m m rlc m - - 1+n s clr m m 0 - - - 1 s bclr m.b m.b 0 - - - 1+n bset m.b m.b 1 - - - 1+n b0bclr m.b m(bank 0).b 0 - - - 1+n b0bset m.b m(bank 0).b 1 - - - 1+n cmprs a,i zf,c a - i, if a = i, then skip next instruction - 1 + s b cmprs a,m zf,c a ? m, if a = m, then skip next instruction - 1 + s r incs m a m + 1, if a = 0, then skip next instruction - - - 1+ s a incms m m m + 1, if m = 0, then skip next instruction - - - 1+n+s n decs m a m - 1, if a = 0, then skip next instruction - - - 1+ s c decms m m m - 1, if m = 0, then skip next instruction - - - 1+n+s h bts0 m.b if m.b = 0, then skip next instruction - - - 1 + s bts1 m.b if m.b = 1, then skip next instruction - - - 1 + s b0bts0 m.b if m(bank 0).b = 0, then skip next instruction - - - 1 + s b0bts1 m.b if m(bank 0).b = 1, then skip next instruction - - - 1 + s jmp d pc15/14 rompages1/0, pc13~pc0 d - - - 2 call d stack pc15~pc0, pc15/14 rompages1/0, pc13~pc0 d - - - 2 m ret pc stack - - - 2 i reti pc stack, and to enable global interrupt - - - 2 s push to push acc and pflag (except nt0, npd bit) into buffers. - - - 1 c pop to pop acc and pflag (except nt0, npd bit) from buffers. 1 nop no operation - - - 1 note: 1. ?m? is system register or ram. if ?m? is system registers then ?n? = 0, otherwise ?n? = 1. 2. if branch condition is true then ?s = 1?, otherwise ?s = 0?.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 99 version 1.0 12 development tool sonix provides ice (in circuit emulation), ide (integrate d development environment), ev-kit and firmware library for usb application development. ice and ev-kit are external hardwa re device and ide is a friendly user interface for firmware development and emulation. 12.1 ice (in circuit emulation) the ice called ?sn8ice2k-fs_usb_1.0? z support sn8p2212 serial microcontro ller full function emulation. z not support ez-writer operation.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 100 version 1.0 12.2 sn8p2213 ev-kit sn8p2213 ev-kit includes ice interface, gpio interface and vreg 3.3v power supply. z ice interface: level shift peripheral circuit. z 3.3v power supply: use 3.3v ldo to supply 3.3v power for vreg pin. z enable/disable vdd power.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 101 version 1.0 13 electrical characteristic 13.1 absolute maximum rating supply voltage (vdd)????????????????????????????????????????????.?????? - 0.3v ~ 6.0v input in voltage (vin)????????????????????????????????????????????.? vss ? 0.2v ~ vdd + 0.2v operating ambient temperature (topr) sn8p2212/121/13p, sn8p2212/121/13s, SN8P22121/13x???????????...???????????. 0 c ~ + 70 c storage ambient temperature (tstor) ?????????????????????????.???????????????? ?30 c ~ + 125 c 13.2 electrical characteristic (all of voltages refer to vss, vdd = 5.0v, fosc = 3.579545mhz, ambient temperature is 25 c unless otherwise note.) parameter sym. description min. typ. max. unit vdd1 normal mode except usb transmitter specifications, vpp = vdd 3.0 5 5.5 v operating voltage vdd2 usb mode 4.25 5 5.25 v ram data retention voltage vdr - 1.5* - v vdd rise rate vpor vdd rise rate to ensure power-on reset 0.05 - - v/ms vil1 all input ports vss - 0.3vdd v input low voltage vil2 reset pin vss - 0.2vdd v vih1 all input ports 0.7vdd - vdd v input high voltage vih2 reset pin 0.9vdd - vdd v reset pin leakage current il ekg vin = vdd - - 2 ua i/o port pull-up resistor rup vin = vss , vdd = 5v 50 100 150 k ? i/o port input leakage current ilekg pull-up resistor disable, vin = vdd - - 2 ua i/o output source current ioh vop = vdd ? 0.5v 10 12* sink current iol vop = vss + 0.5v 10 15* ma intn trigger pulse width tint0 int0 inte rrupt request pulse width 2/fcpu - - cycle regulator current i vreg max regulator output current, vcc > 4.35 volt with 10uf to gnd 60 ma regulator gnd current i vreg nl no loading. reg pin output 3.3v ((regulator enable) 150 ua vreg1 v cc > 4.35v, 0 < temp < 40c, i vreg Q 60 ma with 10uf to gnd 3.0 3.6 v regulator output voltage vreg2 v cc > 4.35v, 0 < temp < 40c, i vreg Q 25 ma with 10uf to gnd 3.1 3.6 v idd1 normal mode (no loading, fcpu = fosc/4) vdd= 5v, 4mhz - - 2.5 5 ma idd2 slow mode (internal low rc) vdd= 5v, 32khz - 20 40 ua idd3 sleep mode vdd= 5v - 10 20 ua vdd= 5v, 4mhz - 0.6 1.2 ma supply current (regulator disable) idd4 green mode (no loading, fcpu = fosc/4 watchdog disable) vdd=5v, ilrc 32khz - 15 30 ua lvd voltage vdet0 low voltage reset level. 2.0 2.4 2.9 v * these parameters are for design reference, not tested.
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 102 version 1.0 14 otp programming pin 14.1 the pin assignment of easy writer transition board socket easy writer jp1/jp2 easy writer jp3 (mapping to 48-pin text tool) vss 2 1 vdd dip1 1 48 dip48 ce 4 3 clk/pgclk dip2 2 47 dip47 oe/shiftdat 6 5 pgm/otpclk dip3 3 46 dip46 d0 8 7 d1 dip4 4 45 dip45 d2 10 9 d3 dip5 5 44 dip44 d4 12 11 d5 dip6 6 43 dip43 d6 14 13 d7 dip7 7 42 dip42 vpp 16 15 vdd dip8 8 41 dip41 rst 18 17 hls dip9 9 40 dip40 alsb/pdb 20 19 - dip10 10 39 dip39 jp1 for mp transition board dip11 11 38 dip38 dip12 12 37 dip38 dip13 13 36 dip36 dip14 14 35 dip35 dip15 15 34 dip34 dip16 16 33 dip33 dip17 17 32 dip32 dip18 18 31 dip31 dip19 19 30 dip30 dip20 20 29 dip29 dip21 21 28 dip28 dip22 22 27 dip27 dip23 23 26 dip26 dip24 24 25 dip25 jp3 for mp transition board
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 103 version 1.0 14.2 programming pin mapping programming information of sn8p2213 series chip name sn8p2213k/s/x SN8P22121p/s/x sn8p2212p/s ez writer / mp writer connector otp ic / jp3 pin assigment number name number pin number pin number pin 1 vdd 19 vdd 17 vdd 16 vdd 2 gnd 15 vss 13 vss 12 vss 3 clk 6 p5.0 6 p5.0 6 p5.0 4 ce - - - - - - 5 pgm 3 p1.0 3 p1.0 3 p1.0 6 oe 4 p5.1 4 p5.1 4 p5.1 7 d1 - - - - - - 8 d0 - - - - - - 9 d3 - - - - - - 10 d2 - - - - - - 11 d5 - - - - - - 12 d4 - - - - - - 13 d7 - - - - - - 14 d6 - - - - - - 15 vdd - - - - - - 16 vpp 12 rst 10 rst 9 rst 17 hls - - - - - - 18 rst - - - - - - 19 - - - - - - - 20 alsb/pdb 2 p1.1 2 p1.1 2 p1.1
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 104 version 1.0 15 package information 15.1 sk-dip 24 pin min nor max min nor max symbols (inch) (mm) a - - 0.210 - - 5.334 a1 0.015 - - 0.381 - - a2 0.125 0.130 0.135 3.175 3.302 3.429 d 1.230 1.250 1.280 31.242 31.75 32.51 e 0.300 bsc 7.62 bsc e1 0.252 0.258 0.263 6.4 6.553 5.994 l 0.115 0.130 0.150 2.921 3.302 3.810 b 0.335 0.355 0.375 8.509 9.017 9,525 0 7 15 0 7 15
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 105 version 1.0 15.2 p-dip 20 pin min nor max min nor max symbols (inch) (mm) a - - 0.210 - - 5.334 a1 0.015 - - 0.381 - - a2 0.125 0.130 0.135 3.175 3.302 3.429 d 0.980 1.030 1.060 24.892 26.162 26.924 e 0.300 7.620 e1 0.245 0.250 0.255 6.223 6.350 6.477 l 0.115 0.130 0.150 2.921 3.302 3.810 b 0.335 0.355 0.375 8.509 9.017 9.525 0 7 15 0 7 15
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 106 version 1.0 15.3 p-dip 18 pin min nor max min nor max symbols (inch) (mm) a - - 0.210 - - 5.334 a1 0.015 - - 0.381 - - a2 0.125 0.130 0.135 3.175 3.302 3.429 d 0.880 0.900 0.920 22.352 22.860 23.368 e 0.300 7.620 e1 0.245 0.250 0.255 6.223 6.350 6.477 l 0.115 0.130 0.150 2.921 3.302 3.810 b 0.335 0.355 0.375 8.509 9.017 9.525 0 7 15 0 7 15
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 107 version 1.0 15.4 sop 24 pin min nor max min nor max symbols (inch) (mm) a - - 0.104 - - 2.642 a1 0.004 - - 0.102 - - d 0.599 0.600 0.624 15.214 15.24 15.84 e 0.291 0.295 0.299 7.391 7.493 7.595 h 0.394 0.407 0.419 10.008 10.337 10.643 l 0.016 0.035 0.050 0.406 0.889 1.270 0 4 8 0 4 8
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 108 version 1.0 15.5 sop 20 pin min nor max min nor max symbols (inch) (mm) a 0.093 0.099 0.104 2.362 2.502 2.642 a1 0.004 0.008 0.012 0.102 0.203 0.305 d 0.496 0.502 0.508 12.598 12.751 12.903 e 0.291 0.295 0.299 7.391 7.493 7.595 h 0.394 0.407 0.419 10.008 10.325 10.643 l 0.016 0.033 0.050 0.406 0.838 1.270 0 4 8 0 4 8
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 109 version 1.0 15.6 sop 18 pin min nor max min nor max symbols (inch) (mm) a 0.093 0.099 0.104 2.362 2.502 2.642 a1 0.004 0.008 0.012 0.102 0.203 0.305 d 0.447 0.455 0.463 11.354 11.557 11.760 e 0.291 0.295 0.299 7.391 7.493 7.595 h 0.394 0.407 0.419 10.008 10.325 10.643 l 0.016 0.033 0.050 0.406 0.838 1.270 0 4 8 0 4 8
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 110 version 1.0 15.7 ssop 24 pin min nor max min nor max symbols (inch) (mm) a 0.053 0.064 0.069 1.346 1.625 1.752 a1 0.004 0.006 0.010 0.101 0.152 0.254 a2 - - 0.059 - - 1.499 d 0.337 0.341 0.344 8.559 8.661 8.737 e 0.228 0.236 0.244 5.791 5.994 6.197 e1 0.150 0.154 0.157 3.81 3.911 3.987 b 0.008 - 0.012 0.203 - 0.304 c 0.007 - 0.010 0.177 - 0.254 [e] 0.025 basic 0.635 basic l 0.016 0.025 0.050 0.406 0.635 1.27 l1 0.041 basic 1.041 basic 0 - 8 0 - 8
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 111 version 1.0 15.8 ssop 20 pin min nor max min nor max symbols (inch) (mm) a 0.053 0.063 0.069 1.350 1.600 1.750 a1 0.004 0.006 0.010 0.100 0.150 0.250 a2 - - 0.059 - - 1.500 b 0.008 0.010 0.012 0.200 0.254 0.300 c 0.007 0.008 0.010 0.180 0.203 0.250 d 0.337 0.341 0.344 8.560 8.660 8.740 e 0.228 0.236 0.244 5.800 6.000 6.200 e1 0.150 0.154 0.157 3.800 3.900 4.000 [e] 0.025 0.635 h 0.010 0.017 0.020 0.250 0.420 0.500 l 0.016 0.025 0.050 0.400 0.635 1.270 l1 0.039 0.041 0.043 1.000 1.050 1.100 zd 0.059 1.500 y - - 0.004 - - 0.100 0 - 8 0 - 8
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 112 version 1.0 16 marking definition 16.1 introduction there are many different types in sonix 8-bit mcu production line. this note listed the produ ction definition of all 8-bit mcu for order or obtain information. this definition is only for blank otp mcu. 16.2 marking indetification system title sonix 8-bit mcu production rom type p=otp material b = pb-free package g = green package temperature range - = 0 ~ 70 d = -40 ~ 85 shipping package w = wafer h = dice k = sk-dip p = p-dip s = sop x = ssop q = lqfp device device part no. sn8 x part no. x x x
sn8p2212 series usb 1.1 full-speed 8-bit micro-controller sonix technology co., ltd page 113 version 1.0 16.3 marking example name rom type device package temperature material sn8p2213kb otp 2213 sk-dip 0 ~70 pb-free package sn8p2213sb otp 2213 sop 0 ~70 pb-free package SN8P22121xb otp 22121 ssop 0 ~70 pb-free package sn8p2212pg otp 2212 p-dip 0 ~70 green package sn8p2212sg otp 2212 sop 0 ~70 green package SN8P22121xg otp 22121 ssop 0 ~70 green package sn8p2213w otp 2213 wafer 0 ~70 - sn8p2213h otp 2213 dice 0 ~ 70 - 16.4 datecode system x x x x xxxxx year month 1=january 2=february . . . . 9=september a=october b=november c=december sonix internal use day 1=01 2=02 . . . . 9=09 a=10 b=11 . . . . 03= 2003 04= 2004 05= 2005 06= 2006 . . . .


▲Up To Search▲   

 
Price & Availability of SN8P22121

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X